Re: Parameter expansion, patterns and fnmatch

2016-09-02 Thread Herbert Xu
backslash and is not part of a bracket expression produces undefined results. > This also affects > > case [a in [?) echo ok ;; *) echo bad ;; esac > > which should print ok. Even ksh prints bad here. I would however consider a patch that simplifies the code in the

Re: [BUG] regression in builtin echo

2016-09-02 Thread Herbert Xu
s). > For example: > echo 'a\cb' c; echo d > shall write "ad" followed by a newline. Works for me: $ build/src/dash -c "echo 'a\cb' c; echo d" ad $ AFAICS my patch doesn't change \c handling at all. When we hit \c print_escape_str will return 0x1

Re: Parameter expansion, patterns and fnmatch

2016-09-02 Thread Herbert Xu
so buggy. Good luck writing a script with an unquoted [ expecting it to be portable :) -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the

Re: Parameter expansion, patterns and fnmatch

2016-09-02 Thread Herbert Xu
nt I think we should pretty much give up on POSIX compliance the way it's headed. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash"

Re: Parameter expansion, patterns and fnmatch

2016-09-02 Thread Herbert Xu
On Fri, Sep 02, 2016 at 09:49:53AM -0500, Eric Blake wrote: > On 09/02/2016 09:29 AM, Herbert Xu wrote: > > On Fri, Sep 02, 2016 at 09:25:15AM -0500, Eric Blake wrote: > >> > >>>> This also affects > >>>> > >>>> case [a in [?) ech

Re: Parameter expansion, patterns and fnmatch

2016-09-03 Thread Herbert Xu
h has never worked this way. What's worse is that your patch changes dash's behaviour in a way that is inconsistent with every shell out there except bash. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.tx

Re: Parameter expansion, patterns and fnmatch

2016-09-03 Thread Herbert Xu
Reported-by: Olof Johansson Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index 36bea76..2a50830 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1584,14 +1584,14 @@ pmatch(const char *pattern, const char *string) p++;

Re: where to obtain dash 0.5.9.1?

2017-03-09 Thread Herbert Xu
I'm in the process of fixing it. For the time being the git tree is the best place to get the source code. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the

Re: where to obtain dash 0.5.9.1?

2017-06-23 Thread Herbert Xu
On Thu, May 11, 2017 at 09:55:46AM -0500, Eduardo Bustamante wrote: > On Thu, Mar 9, 2017 at 5:41 AM, Herbert Xu > wrote: > [...] > > I'm in the process of fixing it. For the time being the git tree > > is the best place to get the source code. > > Hi H

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-02-23 Thread Herbert Xu
such as "${var#\[}" This patch restores the original behaviour for the buggy case while keeping the naked backslash for the quoted pattern case. Fixes: 7cfd8be0dc83 ("[EXPAND] Move parse-time quote flag...") Reported-by: Denys Vlasenko Suggested-by: Harald van Dijk Signed

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-02-24 Thread Herbert Xu
CCTL,CCTL,CCTL,CCTL, CCTL,CCTL,CCTL,CCTL, Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the b

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-01 Thread Herbert Xu
arser currently does not understand nested quoting in patterns at all. That is, if your parameter expansion are within double quotes, then dash at the parser level will consider the pattern to be double-quoted. Thus any nested single-quotes will be literals instead of actual quotes. If we fix this

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-02 Thread Herbert Xu
I'll see if I can get that working. Yes but that's overkill just to fix single quote within patterns. We already support nested double-quotes in patterns correctly. As single quotes cannot nest, it should be an easy fix. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-02 Thread Herbert Xu
ng another local variable, then the parse of the nested ${y-} would > clobber that variable. I don't see why that's hard. You just need to remember whether you're in a pattern context (i.e., after a %/%% or #/##). If you are, then you need to go back to basesyntax instead of

Re: dash tested against ash testsuite: 17 failures

2018-03-06 Thread Herbert Xu
r, your patch also breaks here- document parsing when the delimiter is a single backslash. cat << "\" \ If you can fix these two problems it should be good to go. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key:

Re: [v2] trap: fix memory leak in exitshell()

2018-03-06 Thread Herbert Xu
> foo() { > true > } > trap foo EXIT > > Fix by properly freeing the trap pointer in exitshell(). > > Signed-off-by: Andreas Bofjall This is not needed because we're about to exit so all memory will be going back to the OS. Cheer

Re: Don't execute binary files if execve() returned ENOEXEC.

2018-03-06 Thread Herbert Xu
is imperfect, both false positives and false negatives can occur. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a

Re: Greater resolution in test -nt / test -ot

2018-03-06 Thread Herbert Xu
; } > > static int > > I could use greater resolution in `test -nt` / `test -ot`, and st_mtim > field is standardized under POSIX.1-2008 (or so stat(2) says). Sure. But your patch is corrupted. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/

Re: dash tested against ash testsuite: 17 failures

2018-03-06 Thread Herbert Xu
cuments. It has to be moved after it. IOW I think you should leave the pgetc's before CHECKEND as is, which also means keeping some of the CBACK processing as is. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/p

Re: [PATCH] fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))

2018-03-06 Thread Herbert Xu
exact same set of errors to be detected >> on non-glibc systems. > > That makes sense, thanks. Could you resend your patch with this change please? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt --

Re: [PATCH] fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))

2018-03-06 Thread Herbert Xu
snip] >> Which is better? > > That other patch only fixes it for the unset case, not for the empty > case, so I think the recent one is better. Yes, yours is better but please resend it with the ERANGE change as suggested. Thanks, -- Email: Herbert Xu Home Page:

Re: dash tested against ash testsuite: 17 failures

2018-03-06 Thread Herbert Xu
getc_eatbnl() are conditional > on syntax!=SQSYNTAX, there shouldn't be a problem. It would be a different > story if the delimiter could be an unquoted backslash, but thankfully that > is not possible. Good point. In that case please resend it with the pgetc2 change and it should be good to

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-07 Thread Herbert Xu
to go. This patch also fixes removes any backslashes that precede right braces when they are present within a parameter expansion context. The idea of a recursive parser is based on a patch by Harald van Dijk. Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index 2a50830

Re: dash tested against ash testsuite: 17 failures

2018-03-07 Thread Herbert Xu
On Wed, Mar 07, 2018 at 07:19:56PM +0100, Harald van Dijk wrote: > On 3/7/18 7:51 AM, Herbert Xu wrote: > >On Wed, Mar 07, 2018 at 07:49:16AM +0100, Harald van Dijk wrote: > >> > >>This was wrong in the original patch, but I'm not seeing it in the updated >

[PATCH v2] parser: Add syntax stack for recursive parsing

2018-03-07 Thread Herbert Xu
t this allows us to remove the naked backslashes for patterns within double-quotes, which means that EXP_QPAT also has to go. This patch also fixes removes any backslashes that precede right braces when they are present within a parameter expansion context. The idea of a recursive parser is based on

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-03-07 Thread Herbert Xu
r of other shells and I think I will stick with my patch's behaviour for now. In general, if there are disagreements between shells and the standard is not specific enough, I'll pick the approach that results in simpler code. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~

Re: [PATCH v2] parser: Add syntax stack for recursive parsing

2018-03-08 Thread Herbert Xu
On Thu, Mar 08, 2018 at 10:05:01AM +, Martijn Dekker wrote: > Op 08-03-18 om 07:52 schreef Herbert Xu: > > This patch should fix this problem as well as the one Harald identified: > > Tested. It works well on my end. > > Note it leaves one bug Harald's patch fixe

[PATCH v3] parser: Add syntax stack for recursive parsing

2018-03-08 Thread Herbert Xu
braces when they are present within a parameter expansion context, and backslashes that precede double quotes within inner double quotes inside a parameter expansion in a here-document context. The idea of a recursive parser is based on a patch by Harald van Dijk. Signed-off-by: Herbert Xu diff -

[PATCH] parser: Fix single-quoted patterns in here-documents

2018-03-09 Thread Herbert Xu
prints * instead of nothing as it should. The problem is that when we're in sqsyntax context in a here-document, we won't add CTLESC as we should. This patch fixes it: Reported-by: Harald van Dijk Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 3aeb9f6..d86d71e 1

Re: trap: Globally rename pendingsigs to pending_sig

2018-03-10 Thread Herbert Xu
; it hints at being an array or bit mask of pending singnals. > > Signed-off-by: Denys Vlasenko > CC: dash@vger.kernel.org Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscrib

Re: man: Small cleanup for Command Line Editing

2018-03-10 Thread Herbert Xu
e editing and place sh > into vi insert mode. Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a m

Re: builtin: describe_command - fix incorrect path

2018-03-10 Thread Herbert Xu
e is correct, and printing tracked aliases is > intentional. > > If it's desirable to drop that feature, then it should be dropped > completely, code shouldn't be left in that can no longer be used. But > it's possible to keep it working: how about this instead? >

Re: expand: 'nolog' and 'debug' options cause "$-" to wreak havoc

2018-03-10 Thread Herbert Xu
; set +o debug; echo "|$- are the options|"' > > | > > |uCf are the options| > > This turned out to be easy to fix. The routine producing the "$-" > expansion failed to skip options for which there is no option letter, > but only a long-form name

Re: histedit: fix build with musl libc

2018-03-10 Thread Herbert Xu
eclared (first use in this function) > optreset = 1; optind = 1; /* initialize getopt */ > ^~~~ > > Signed-off-by: Baruch Siach Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: expand: Remove dependency on fmatch.h if it does not exit

2018-03-10 Thread Herbert Xu
for fnmatch(3) and > supplies its own implementation if necessary, but fnmatch.h is always > included. > > Let me know what you think. > > Regards, > Rink > > Do not assume we can include fnmatch.h > > Signed-off-by: Rink Springer Patch applied. Thanks. -- Email

Re: input: Fix here-document redirection with vi/emacs on

2018-03-10 Thread Herbert Xu
te so that parsing > can continue. But when getprompt() is called by el_gets(), it knows > nothing about this. > > The whole call to el_gets() can be surrounded by another > pushstackmark()/popstackmark() pair to solve the problem, as attached. Patch applied. Thanks. -- Email:

Re: mystring: fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))

2018-03-10 Thread Herbert Xu
On Wed, Mar 07, 2018 at 01:03:26PM +, Martijn Dekker wrote: > Op 07-03-18 om 06:26 schreef Herbert Xu: > > Martijn Dekker wrote: > >> > >>> Since base is always a constant 0 or a constant 10, never a > >>> user-provided value, the only error that

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
g backquotes in a here-document EOF mark is broken because dash tries to do command substitution on it. This patch fixes it by checking whether we're looking for an EOF mark during tokenisation. Reported-by: Harald van Dijk Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c in

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
;< " " IOW it's not clear that "word" in this context necessarily follows the same rules used during normal tokenisation. Anyway, dash has had CHKEOFMARK since 2007 so this is just an extension of existing behaviour. Cheers, -- Email: Herbert Xu Home Page: ht

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
ch you conveniently dismissed :) > For your example, does any shell, including dash, *not* treat this as a > multi-line heredoc delimiter consisting of a newline character (which may or > may not be matched by two blank lines, depending on the shell)? Yes, almost every shell fails with

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
it's actually the same reason as the second, namely newlines are not accepted within parameter substitution. If we fixed this then it should work correctly. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herber

Re: Greater resolution in test -nt / test -ot

2018-03-21 Thread Herbert Xu
On Wed, Mar 07, 2018 at 05:32:29PM +, Martijn Dekker wrote: > Op 07-03-18 om 15:46 schreef Martijn Dekker: > > Op 06-03-18 om 09:19 schreef Herbert Xu: > >> On Thu, Jun 22, 2017 at 10:30:02AM +0200, Petr Skočík wrote: > >>> would you be willing to pull somethin

Re: dash tested against ash testsuite: 17 failures

2018-03-21 Thread Herbert Xu
me duplicated backslash-newline handling elsewhere in parser.c. > Replace most of the calls to pgetc() with calls to pgetc_eatbnl() and remove > the duplicated backslash-newline handling. Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http:/

Re: [PATCH] provide .gitignore

2018-03-21 Thread Herbert Xu
Martijn Dekker wrote: > Here's a .gitignore file for the convenience of casual git users. Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send

expand: Fix bugs with words connected to the right of $@

2018-03-22 Thread Herbert Xu
This is actually composed of two bugs. First of all our tracking of quotemark is wrong so anything after "$@" becomes quoted. Once we fix that then the problem is that the first space character after "$@" is not recognised as an IFS. This patch fixes both. Signed-off-by:

Re: [PATCH] don't record empty IFS scan regions

2018-03-22 Thread Herbert Xu
unquoted > $@ and $* incorrectly generate one empty field (they should generate no > fields). Apparently that was a side effect of the above. Please attach a reproducer as I cannot reproduce this problem. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: ht

parser: Allow newlines within parameter substitution

2018-03-22 Thread Herbert Xu
On Fri, Mar 16, 2018 at 11:27:22AM +0800, Herbert Xu wrote: > On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote: > > > > Okay, it can be trivially modified to something that does work in other > > shells (even if it were actually executed), but gets rejected

Re: RFC/Feature request: UTF-8 support

2018-03-22 Thread Herbert Xu
-8. The licenses are bidirectionally > compatible. Perhaps UTF-8 support could be ported over in the other > direction? Maybe Denys Vlanesko could assist. Well if you can show me the code then I can comment :) -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://go

expand: Fix ghost fields with unquoted $@/$*

2018-03-22 Thread Herbert Xu
You're right. The proper fix to this is to ensure that nulonly is not set in varvalue for $*. It should only be set for $@ when it's inside double quotes. In fact there is another bug while we're playing with $@/$*. When IFS is set to a non-whitespace character such as :, $* outside quote

Re: RFC/Feature request: UTF-8 support

2018-03-22 Thread Herbert Xu
ains GPL code. However, they're small and easy to remove/rewrite. So I'd prefer not to add any more GPL code if possible. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this l

Re: expand: Fix ghost fields with unquoted $@/$*

2018-03-23 Thread Herbert Xu
%2} > > This used to print A1 B2 C3, but prints A1 B with your patch. Hmm, it still does on my machine: $ build/src/dash $ unset IFS $ set -- A1 B2 C3 $ echo ${@%2 C3} A1 B $ I'm testing against this commit: commit c166b718b496da63c4df7a0972df2fc6cd38256b Author: Herbert Xu Date: T

Re: expand: Fix ghost fields with unquoted $@/$*

2018-03-23 Thread Herbert Xu
On Fri, Mar 23, 2018 at 10:27:20AM +0100, Harald van Dijk wrote: > On 23/03/2018 10:10, Herbert Xu wrote: > >On Fri, Mar 23, 2018 at 09:27:37AM +0100, Harald van Dijk wrote: > >> > >>Also the above. But it breaks a traditional ash extension: > >> > >>

[PATCH v2] expand: Fix ghost fields with unquoted $@/$*

2018-03-23 Thread Herbert Xu
> original $@ bug. You're right. The proper fix to this is to ensure that nulonly is not set in varvalue for $*. It should only be set for $@ when it's inside double quotes. In fact there is another bug while we're playing with $@/$*. When IFS is set to a non-whitespace chara

Re: expand: Fix ghost fields with unquoted $@/$*

2018-03-23 Thread Herbert Xu
you're interested in implementing that in dash, a relevant test case is > > set -- A1 B2 C3 > unset p > echo ${1%${p+x}${p=?}} ${2%${p+x}${p=?}} ${3%${p+x}${p=?}} > unset p > echo ${@%${p+x}${p=?}} > > In bash and ksh, this is supposed to print, and does print: &

Re: expand: Fix ghost fields with unquoted $@/$*

2018-03-23 Thread Herbert Xu
re sense. But that was at the cost of not eliminating empty fields which violates POSIX. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscrib

builtin: Fix echo performance regression

2018-03-24 Thread Herbert Xu
s slightly better code. Signed-off-by: Herbert Xu diff --git a/src/bltin/printf.c b/src/bltin/printf.c index ec7c8c2..eaf14b6 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -98,20 +98,25 @@ static int print_escape_str(const char *f, int *param, int *array, char *s)

builtin: Move echo space/nl handling into print_escape_str

2018-03-25 Thread Herbert Xu
Currently echocmd uses print_escape_str to do everything apart from printing the spaces/newlines separating its arguments. This patch moves the actual printing into print_escape_str as well using the format parameter. Signed-off-by: Herbert Xu diff --git a/src/bltin/printf.c b/src/bltin

expand: Fix glibc glob(3) support

2018-03-25 Thread Herbert Xu
It's been a while since we disabled glob(3) support by default. It appears to be working now, however, we have to change our code to remove a workaround that now actually prevents it from working. In particular, we no longer use GLOB_NOMAGIC or test GLOB_MAGCHAR. Signed-off-by: Herbert Xu

expand: Fix buffer overflow in expandmeta

2018-03-25 Thread Herbert Xu
patch fixes both problems by calling realloc when necessary. Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index 705fef7..dadac56 100644 --- a/src/expand.c +++ b/src/expand.c @@ -124,7 +124,7 @@ STATIC void expandmeta(struct strlist *, int); #ifdef HAVE_GLOB STATIC void

Re: expand: Fix glibc glob(3) support

2018-03-25 Thread Herbert Xu
ld otherwise require nasty hacks to work around: https://sourceware.org/bugzilla/show_bug.cgi?id=866 So I'll give it some time to filter through before trying it again. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au

Re: expand: Fix buffer overflow in expandmeta

2018-03-25 Thread Herbert Xu
s. Well the fact is that all systems allow paths to exist which are longer than PATH_MAX. Besides, even if we did impose a limit here we'd still have to check that limit at every recursion level which means that the code won't be that much simpler. Cheers, -- Email: Herbert Xu Home Pag

Re: expand: Fix buffer overflow in expandmeta

2018-03-25 Thread Herbert Xu
me); > + expmeta1(expdir, p, endname); > } > } > +toolong: ; > } > closedir(dirp); > if (! atend) > endname[-esc - 1] = esc ? '\\' : '/'; > } Thanks, -- Email: Herbert Xu Home

Re: expand: Fix buffer overflow in expandmeta

2018-03-26 Thread Herbert Xu
On Mon, Mar 26, 2018 at 08:19:02AM +0200, Harald van Dijk wrote: > On 3/26/18 7:12 AM, Herbert Xu wrote: > >FWIW your patch when built with -O2 with gcc 4.7.2 is actually > >16 bytes bigger than my version. > > Interesting. Not sure what might cause that. gcc likes to unro

[PATCH v2] expand: Fix glibc glob(3) support

2018-03-26 Thread Herbert Xu
On Mon, Mar 26, 2018 at 12:27:41AM +0800, Herbert Xu wrote: > > I tried making it work, and it looks like it should work with > the latest glibc as they have just fixed a critical issue that > would otherwise require nasty hacks to work around: > > https://sourc

redir: Fix typo in noclobber code

2018-03-26 Thread Herbert Xu
The noclobber code has a typo in it that causes it to fail. This patch fixes it. Reported-by: Denys Vlasenko Signed-off-by: Herbert Xu diff --git a/src/redir.c b/src/redir.c index f96a76b..71b0f77 100644 --- a/src/redir.c +++ b/src/redir.c @@ -192,7 +192,7 @@ openredirect(union node *redir

Re: [PATCH v2] don't record empty IFS scan regions if not debugging

2018-03-26 Thread Herbert Xu
me, I don't see how that could work performance wise. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message

eval: Reap zombies after built-in commands and functions

2018-03-26 Thread Herbert Xu
and function. Reported-by: Denys Vlasenko Signed-off-by: Herbert Xu diff --git a/src/eval.c b/src/eval.c index 7498f9d..19e06ec 100644 --- a/src/eval.c +++ b/src/eval.c @@ -848,6 +848,8 @@ bail: goto out; } + jp = NULL; + /* Execute the command

eval: Restore input files in evalcommand

2018-03-26 Thread Herbert Xu
When evalcommand invokes a command that modifies parsefile and then bails out without popping the file, we need to ensure the input file is restored so that the shell can continue to execute. Reported-by: Martijn Dekker Signed-off-by: Herbert Xu diff --git a/src/eval.c b/src/eval.c index

expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
k to dash yes I think we should adopt the bash behaviour for pathname expansion and keep the existing case semantics. This patch does exactly that. Note that this patch does not work unless you have already applied https://patchwork.kernel.org/patch/10306507/ because otherwise the opt

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
he same results anyway. If that > stops, then checking the file system for matches becomes required. It doesn't disallow it either. Can you show me a shell that doesn't apply this optimisation? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: ht

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
y have broken POSIX because they always treat backslashes that arise from parameter expansion as literal backslashes. FWIW it wouldn't be hard to iron out the anomalous case of /d\ev. You just have treat the backslash as a metacharacter. Cheers, -- Email: Herbert Xu Home Page: http://gon

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
ould have already been removed by preglob so there should be no difference. The only problem with the metacharacter approach is that glibc's glob(3) probably won't treat it as a metacharacter and therefore it will still behave in the same way as the current bash. Cheers, -- Email: Herbert X

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
ide to enable > --enable-glob by default in the future. As long as you don't include > GLOB_NOESCAPE, then normally, it should be taken as escaping the next > character, but it might still trigger GLOB_NOMAGIC to return early. If it > does, I'd take that as a glibc bug, but

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
eta > character. Oh I though you were talking about test/[, I didn't see the set. But why would someone do set "["? > Then, how about moving some of expmeta()'s checks to return early outside of > it, so that they can also be done in the glob() case? We could. Cheers

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
o just drop the /d\ev issue and use the bash behaviour until such a time that bash changes or POSIX changes. It's such an unlikely case as why would anyone knowingly put backslash into a variable and expecting pathname expansion to remove it without actually using real magic characters. Cheer

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
ented it. $ ksh -c 'a="/usr/bin/\["; printf "%s\n" $a' /usr/bin/\[ $ If you really wanted to do this in a script, the portable way is $ ksh -c 'a="/usr/bin/[[]"; printf "%s\n" $a' /usr/bin/[ $ Cheers, -- Email: Herbert Xu Home Page: http://

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
emoval is not done on the portion of the word that results from parameter expansion. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in th

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-27 Thread Herbert Xu
unquoted, it > becomes possible for the next character to be the terminating '\0'. This code has always had to deal with naked backslashes. Can you show me the exact pattern that results in the overread? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.a

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
er shells as a > reason for not doing it properly. It's logical for dash because this aligns the behaviour of pathname expansion with case pattern matching. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.t

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
On Wed, Mar 28, 2018 at 09:38:04AM +0200, Harald van Dijk wrote: > > Also, it's just as logical to restore the case pattern matching to its > traditional behaviour to align it with pathname expansion. No I think that makes no sense and clearly contradicts POSIX. Cheers, -- Ema

Re: expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
On Wed, Mar 28, 2018 at 08:44:28AM +0200, Harald van Dijk wrote: > > Test case: > > $v='*\' > set -- $v I don't see how this would cause an overrun, can you please explain it for me? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.

[PATCH v2] expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
} while (*p++); @@ -1349,7 +1348,7 @@ expmeta(char *name, unsigned name_len, unsigned expdir_len) if (name < start) { p = name; do { - if (*p == '\\') + if (*p == '\\' && p[1

Re: [PATCH v2] expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
\; case \\ in $v) echo bug;; esac > > bash prints nothing, dash 0.5.9.1 prints bug. Other shells don't count since > they interpret $v differently. Indeed bash seems to do something different for case matches. Since bash itself is inconsistent, and POSIX unclear, I have opted to be cons

Re: [PATCH v2] expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
is no way to actually produce an unescaped backslash in these shells. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body

Re: [PATCH v2] expand: Do not quote backslashes in unquoted parameter expansion

2018-03-28 Thread Herbert Xu
ehaviour is inconsistent at best. So at this point I am not going to change long-standing dash behaviour on the unescaped backslash at the end of a pattern. If and when other shells move on this issue then we can reexamine this. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au

Re: "parser: Fix backquote support in here-document EOF mark" incomplete

2018-04-01 Thread Herbert Xu
On Sun, Apr 01, 2018 at 04:34:49PM +0200, Denys Vlasenko wrote: > Hi Herbert, > > Regarding: > > commit c166b718b496da63c4df7a0972df2fc6cd38256b > Author: Herbert Xu > Date: Thu Mar 15 18:27:30 2018 +0800 > > parser: Fix backquote support in here-document EO

parser: Fix parsing of ${}

2018-04-02 Thread Herbert Xu
han during parsing. Fixes: 3df3edd13389 ("[PARSER] Report substition errors at...") Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 6a8a4a4..efa8060 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1262,7 +1262,7 @@ varname:

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-04-02 Thread Herbert Xu
look for ENDVAR while innerdq is true. echo "${x#"${x+''}"''} This patch fixes it by pushing the syntax stack if innerdq is true and we enter a new parameter expansion. This patch also fixes a corner case where a bad substitution error occurs within ari

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-04-02 Thread Herbert Xu
-\`-\--\z-\*-\?- > > (Second and third line have \t expanded to tab. Mail-mangled to spaces, > likely) > > Apart from \t, note that in second heredoc line there is a difference in how > `echo '\"'` was handled: bash prints \", dash prints ". FWIW ksh93

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-04-02 Thread Herbert Xu
\n Write a . \r Write a . \t Write a . \v Write a . \\ Write a character. \0num Write an 8-bit value that is the zero, one, two, or three-digit octal number num. Cheers, -- Email: Herbert Xu

eval: Variable assignments on functions are no longer persistent

2018-04-04 Thread Herbert Xu
I have considered the exporting the variables during the function execution but have decided against it because: 1) It makes the code bigger. 2) dash has never done this in the past. 3) You cannot use this portably anyway. Reported-by: Dirk Fieldhouse Signed-off-by: Herbert Xu diff --

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-04-04 Thread Herbert Xu
gt; I think it should retain \" as \". It wasn't the backquote that removed the backslash but the here- document. This is expected behaviour as here-documents behave like double quotes so the backslash is indeed special when it precedes a double quote. As I said ksh93 does the same

Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-04-04 Thread Herbert Xu
h is already gone so the double quote becomes an actual double quote rather than a literal one. This is how it works in ksh93 too. If you want to have guarantee a literal backslash inside a here- document then you should always do \\. Cheers, -- Email: Herbert Xu Home Page: http://gondor

Re: eval: Variable assignments on functions are no longer persistent

2018-04-07 Thread Herbert Xu
's not relevant. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majord...@vger.kernel.org More majordomo in

Re: [PATCH] [v5] quote arguments in xtrace output

2018-04-19 Thread Herbert Xu
e. So that means no features unless absolutely necessary. As such I cannot accept this patch as it is. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubsc

Re: [PATCH] expand: remove unnecessary code in backquote expansion

2018-04-19 Thread Herbert Xu
. So let's keep it around for now until we get things such as `jobs -p` to work. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash"

Re: dash bug

2018-04-19 Thread Herbert Xu
uot;} > --- > > dash will output the following error: > ./test.sh: Syntax error: Unterminated quoted string Sorry, I was a bit slack in pushing out the pending patches. It should be fixed in the git tree now. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.

Re: Add subdir-objects to AM_INIT_AUTOMAKE

2018-04-19 Thread Herbert Xu
see and, if the warning text is to be believed, then > the warning will eventually become an error. Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the li

Re: dash.1 - correct typos, iff -> if

2018-04-19 Thread Herbert Xu
if >> you all are happy enough to keep it 'as is', or can resubmit if you >> think it's warranted. > > I think the simple fact that it came up here is evidence that this is > too jargony for a manual. Patch attached. Patch applied. Thanks. -- Email: Herber

Re: [PATCH] [v5] quote arguments in xtrace output

2018-04-26 Thread Herbert Xu
On Thu, Apr 19, 2018 at 02:47:42PM +0200, Martijn Dekker wrote: > > Would you accept it if it were a configure option, disabled by default (like > linking with libedit)? Sorry, I don't think this particular feature would fit well with a configuration option. Cheers, -- Email: He

<    1   2   3   4   5   6   >