Re: [PATCH] parser: Fix regression on ${#10} expansion

2021-02-10 Thread Herbert Xu
On Wed, Feb 10, 2021 at 07:30:17PM +0400, Vladimir N. Oleynik wrote: > > But I do not show this patch in > https://git.kernel.org/pub/scm/utils/dash/dash.git/ > Its ok? It's still in the review process: https://patchwork.kernel.org/project/dash/list/ Thanks, -- Email: Herb

[PATCH] parser: Fix regression on ${#10} expansion

2021-02-07 Thread Herbert Xu
} else if (c != '}') { >int cc = c; I would rather test against VSNORMAL. Fixes: 7710a926b321 ("parser: Only accept single-digit parameter...") Reported-by: Vladimir N. Oleynik Signed-off-by: Herbert Xu diff --git a/src/p

Re: [PATCH v2] Cache the expanded prompt for editline

2021-01-14 Thread Herbert Xu
es painful when it is expanded > over and over and does anything non-trivial, even just a command > substitution that runs no external commands. OK, in that case I think it's best to fix this in libedit instead. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~her

Re: [PATCH] Fail if building --with-libedit and can't find libedit

2021-01-12 Thread Herbert Xu
C. McEnroe wrote: > Previously, configure --with-libedit would only fail in the case where > libedit is available but its header file histedit.h is not. > --- > configure.ac | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Patch applied. Thanks. -- Email: Herbert Xu

Re: [PATCH v2] Cache the expanded prompt for editline

2021-01-12 Thread Herbert Xu
actually wanted the prompt to change? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] jobs: Always reset SIGINT/SIGQUIT handlers

2021-01-11 Thread Herbert Xu
On Fri, Jan 08, 2021 at 08:55:41PM +, Harald van Dijk wrote: > On 18/05/2018 19:39, Herbert Xu wrote: > > This patch adds basic vfork support for the case of a simple command. > > ... @@ -879,17 +892,30 @@ forkchild(struct job *jp, union node *

Re: dash 0.5.11.2: somehow falsely waits

2021-01-07 Thread Herbert Xu
ts status through patchwork at: https://patchwork.kernel.org/project/dash/list/ Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: dash 0.5.11.2: somehow falsely waits

2021-01-06 Thread Herbert Xu
;t find the commit though because it appears to be there: https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=6359d7aa739b9f02f622805f4dbddeaf0ae61981 Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: dash 0.5.11.2: somehow falsely waits

2021-01-05 Thread Herbert Xu
anks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: dash 0.5.11.2, busybox sh 1.32.0, FreeBSD 12.2 sh: spring TTOU but should not i think

2021-01-05 Thread Herbert Xu
by default. I think the approach of blocking all signals should be able to resolve this too if anyone cares enough about this case. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] jobs: Block signals during tcsetpgrp

2021-01-05 Thread Herbert Xu
this is by not trying to make the shell start a new > process group, or at least not make it the foreground process group. > Most other shells appear to not try to do this. This patch implements the blocking of SIGTTOU (and everything else) while we call tcsetpgrp. Reported-by: Steffen Nurpmes

Re: set -I is not required by standard, and does not match bash

2021-01-04 Thread Herbert Xu
ess they have all removed this option I'm not going to change it. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] input: Clear unget on RESET

2020-12-23 Thread Herbert Xu
to pungetc") Reported-by: Denys Vlasenko Signed-off-by: Herbert Xu diff --git a/src/input.c b/src/input.c index 4987732..d7c101b 100644 --- a/src/input.c +++ b/src/input.c @@ -87,6 +87,7 @@ INIT { RESET { /* clear input buffer */ basepf.lleft = basepf.nleft = 0; + ba

Re: Bug#976865: Fwd: Bug#974900: dash removes trailing slash from script arguments

2020-12-10 Thread Herbert Xu
On Thu, Dec 10, 2020 at 10:20:29AM -0500, Jeff King wrote: > > It seems like it happens for "foo/", too. If I compile: I think the key is that dash uses GLOB_NOMAGIC. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana

Re: Fwd: Bug#974900: dash removes trailing slash from script arguments

2020-12-10 Thread Herbert Xu
ot;foo". This should return no match. If you change the pattern to "foo/", then it also matches but returns with the string "foo/" as expected. The only flag we pass to glob(3) is GLOB_NOMAGIC. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Bug#976865: Fwd: Bug#974900: dash removes trailing slash from script arguments

2020-12-10 Thread Herbert Xu
the problem doesn't occur for "foo/". Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Bug#976865: Fwd: Bug#974900: dash removes trailing slash from script arguments

2020-12-09 Thread Herbert Xu
pana.org.au/ Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Changes to job handling cause hangs in wait

2020-12-06 Thread Herbert Xu
f that child. Since the child was killed, we need to ignore that, so this works for me: wait $MONPID 2> /dev/null || : Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] jobs: Only block in waitcmd on first run

2020-12-01 Thread Herbert Xu
Only clear gotsigchld when waiting...") Reported-by: Michael Biebl Signed-off-by: Herbert Xu diff --git a/src/jobs.c b/src/jobs.c index 3417633..516786f 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -81,6 +81,7 @@ #define DOWAIT_NONBLOCK 0 #define DOWAIT_BLOCK 1 #define DOWAIT_WAITCMD

Re: Changes to job handling cause hangs in wait

2020-12-01 Thread Herbert Xu
ndeed a change in behaviour which is undesirable. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Changes to job handling cause hangs in wait

2020-12-01 Thread Herbert Xu
f the bash script rather than bash itself. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Changes to job handling cause hangs in wait

2020-12-01 Thread Herbert Xu
On Tue, Dec 01, 2020 at 10:55:06AM +, Harald van Dijk wrote: > > You wrote: "So the problem is really in the parent of this shell, which > appears to be bash:" You should read my follow-up email too that suggested changing the systemd script. Cheers, -- Email: Herbert

Re: Changes to job handling cause hangs in wait

2020-12-01 Thread Herbert Xu
are no other children around that you don't know of. In the original bug, the proper solution is to wait on the PID that the script just sent a kill signal to. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Changes to job handling cause hangs in wait

2020-12-01 Thread Herbert Xu
for the last command in a list when it can just > exec() without a fork() instead. A minimal example without an explicit exec > is > > bash -c 'dash -c ": & wait" <(sleep 1d)' I'm not sure about that because bash itself is still hanging around, if it were really the -c optimisation then bash should not appear in the ps output at all. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Changes to job handling cause hangs in wait

2020-11-30 Thread Herbert Xu
On Tue, Dec 01, 2020 at 05:06:18PM +1100, Herbert Xu wrote: > > For some reason this is causing the final two tee's to be created > as children of debian/tests/timedated rather than the bash shell. An alternative to changing the parent is of course to do wait $MONP

Re: Changes to job handling cause hangs in wait

2020-11-30 Thread Herbert Xu
On Tue, Dec 01, 2020 at 04:42:03PM +1100, Herbert Xu wrote: > > Nevermind, I see that the script has been modified to use bash. > > I can reproduce the problem now so it's all good. OK the problem is this: sh -c 'sleep 1d& exec $MYSHELL -c "sleep 1& w

Re: Changes to job handling cause hangs in wait

2020-11-30 Thread Herbert Xu
On Tue, Dec 01, 2020 at 04:38:37PM +1100, Herbert Xu wrote: > > FWIW I'm unable to reproduce it with autopkgtest. This is what > I get: > > root@test0:~# autopkgtest --test-name=timedated systemd-246.6/ -B -- lxc -s > autopkgtest-sid > autopkgtest [16:32:45]:

Re: Changes to job handling cause hangs in wait

2020-11-30 Thread Herbert Xu
PASS autopkgtest [16:33:32]: summary timedatedPASS root@test0:~# Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Fwd: Bug#974900: dash removes trailing slash from script arguments

2020-11-16 Thread Herbert Xu
Andrej Shadura wrote: > > this is another bug report I have received. This is a bug in glob(3). Please dup and reassign to libc6. There is a patch in the queue to disable glob by default again. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key

Re: Changes to job handling cause hangs in wait

2020-11-16 Thread Herbert Xu
reproduce it, could you please run the offending script under strace -f and send me the result? That should pin-point the problem. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] shell: Disable glob again as it strips traing slashes

2020-11-15 Thread Herbert Xu
On Mon, Nov 16, 2020 at 01:47:48PM +1100, Herbert Xu wrote: > René Scharfe wrote: > > > > on Debian testing dash eats trailing slashes of parameters that happen > > to be regular files when expanding "$@". Example: > > > > $ rm -f foo bar

Re: [PATCH] shell: Enable fnmatch/glob by default

2020-11-15 Thread Herbert Xu
az foo/ bar/ ./ > baz foo bar/ ./ In fact you just have to do dash -c 'echo bar\/' This is a bug in glob(3). It's stripping the slash. I guess we'll just have to disable glob again. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] shell: Group readdir64/dirent64 with open64

2020-07-21 Thread Herbert Xu
ar build failures. Reported-by: Martijn Dekker Signed-off-by: Herbert Xu diff --git a/configure.ac b/configure.ac index 955e2bb..ab3c02e 100644 --- a/configure.ac +++ b/configure.ac @@ -145,10 +145,6 @@ AC_CHECK_FUNC(stat64,, [ AC_DEFINE(fstat64, fstat, [64-bit operations are the sam

Re: [PATCH] dash: man pages: fix formatting

2020-07-08 Thread Herbert Xu
c: ./src/dash.1:2330:6: STYLE: referenced manual not found: Xr csh 1 > > Signed-off-by: Bjarni Ingi Gislason > --- > src/bltin/echo.1 | 6 +++-- > src/bltin/printf.1 | 13 ++- > src/bltin/test.1 | 2 +- > src/dash.1 | 57 +++--- > 4 files changed, 45 insertions(+), 33 deletions(-) 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: Status of set -o pipefail

2020-06-30 Thread Herbert Xu
] https://www.spinics.net/lists/dash/msg01888.html AFAIK nobody has actually posted a patch to this list. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] Don't include config.h when building helpers using the native compiler

2020-06-22 Thread Herbert Xu
./../src/trap.c ../../src/output.c ../../src/bltin/printf.c ../../src/system.c ../../src/bltin/test.c ../../src/bltin/times.c ../../src/var.c I'm not cross-compiling though. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] eval: Check nflag in evaltree instead of cmdloop

2020-06-04 Thread Herbert Xu
This patch moves the nflag check from cmdloop into evaltree. This is so that nflag will be in force even if we enter the shell via a path other than cmdloop, e.g., through sh -c. Reported-by: Joey Hess Signed-off-by: Herbert Xu diff --git a/src/eval.c b/src/eval.c index d10be38..9476fbb

Re: Bug when parsing redirection syntax error

2020-06-03 Thread Herbert Xu
somewhere and interferes with the next > command to be read. This is because dash needs to clear the unget buffer on reset. Reported-by: Matt Whitlock Fixes: 17db43b58415 ("input: Allow two consecutive calls to pungetc") Signed-off-by: Herbert Xu diff --git a/src/input.c b/src/

[PATCH] jobs: Fix waitcmd busy loop

2020-06-02 Thread Herbert Xu
("jobs: Only clear gotsigchld when waiting...") Signed-off-by: Herbert Xu diff --git a/src/jobs.c b/src/jobs.c index 94bf47e..3417633 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -1135,7 +1135,6 @@ static int dowait(int block, struct job *jp) rpid = 1;

[PATCH] error: Remove USE_NORETURN ifdef

2020-06-02 Thread Herbert Xu
The USE_NORETURN was added because gcc was buggy almost 20 years ago. This is no longer needed and this patch removes it. Signed-off-by: Herbert Xu diff --git a/src/error.h b/src/error.h index 94e30a2..661a8a0 100644 --- a/src/error.h +++ b/src/error.h @@ -116,11 +116,7 @@ void __inton(void

[PATCH] expand: Make glob(3) interruptible by SIGINT

2020-06-02 Thread Herbert Xu
ll be uninterruptible. Signed-off-by: Herbert Xu diff --git a/configure.ac b/configure.ac index ce5feec..955e2bb 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,13 @@ AC_CHECK_FUNC(stat64,, [ [64-bit operations are the same as 32-bit]) ]) +AC_CHECK_FUNC(g

[PATCH] shell: Enable fnmatch/glob by default

2020-05-28 Thread Herbert Xu
As fnmatch(3) and glob(3) from glibc are now working consistently, this patch enables them by default. Signed-off-by: Herbert Xu diff --git a/configure.ac b/configure.ac index dbd97d8..d73b2bf 100644 --- a/configure.ac +++ b/configure.ac @@ -37,9 +37,10 @@ if test "$enable_static" = &

Re: [PATCH] Fix typos

2020-05-28 Thread Herbert Xu
Martin Michlmayr wrote: > Signed-off-by: Martin Michlmayr Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] redir: Retry open64 on EINTR

2020-05-28 Thread Herbert Xu
retry the open64 call if necessary. It also calls sh_error when appropriate. Fixes: 3800d4934391 ("[JOBS] Fix dowait signal race") Reported-by: Samuel Thibault Signed-off-by: Herbert Xu diff --git a/src/input.c b/src/input.c index 17544e7..6103312 100644 --- a/src/input.c +++ b/s

[PATCH] eval: Prevent recursive PS4 expansion

2020-05-26 Thread Herbert Xu
$$] echo done > done > > - dash: (stalls it set -x) > > /tmp > dash test.sh > +export PS4=+ $(date +%T.%N) [$$] > ^C^C This patch fixes the infinite loop caused by repeated expansions of PS4. Reported-by: Yaroslav Halchenko Signed-off-by: Herbert Xu diff --

[PATCH] parser: Get rid of PEOA

2020-05-26 Thread Herbert Xu
stead delays the marking of aliases until the second pgetc. This has the same effect as the current PEOA code while keeping the complexities within the input code. Signed-off-by: Herbert Xu diff --git a/src/input.c b/src/input.c index 17544e7..cf4efdc 100644 --- a/src/input.c +++ b/src/input.c @@

parser: Fix double-backslash nl in old-style command sub

2020-05-26 Thread Herbert Xu
ollowed by a new-line. This patch fixes it by calling pgetc. Reported-by: Matt Whitlock Fixes: 6bbc71d84bea ("parser: use pgetc_eatbnl() in more places") Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 3131045..03c103b 100644 --- a/src/parser.c +++ b/src/parse

[PATCH] parser: Save and restore heredoclist in expandstr

2020-05-17 Thread Herbert Xu
than one started by a signal like SIGINT. Reported-by: Harald van Dijk Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 3131045..54c2861 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1565,10 +1565,11 @@ setprompt(int which) const char * expandstr(const char *

Re: [v3 PATCH] mktokens relative TMPDIR

2020-05-14 Thread Herbert Xu
, > default to /tmp. > > The mkbuiltins script was already hardened to work relative to TMPDIR, > also defaulting to /tmp. > > v2 ensures that TMPDIR is quoted. > v3 adds an extra quotation that prevents extra pathname expansions. > > Signed-off-by: Michael Greenberg Patc

Re: [PATCH] input: Fix compiling against libedit with -fno-common

2020-05-14 Thread Herbert Xu
move the definition as it is not needed. > > Signed-off-by: Jeroen Roovers > Signed-off-by: Mike Gilbert > --- > src/input.c | 4 > 1 file changed, 4 deletions(-) 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: [PATCH] Remove unused expandmeta() flag parameter

2020-05-14 Thread Herbert Xu
On Wed, Apr 29, 2020 at 08:29:53AM +0200, Denys Vlasenko wrote: > Signed-off-by: Denys Vlasenko > --- > src/expand.c | 10 -- > 1 file changed, 4 insertions(+), 6 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ P

shell: Always use explicit large file API

2020-05-07 Thread Herbert Xu
There are some remaining stat/readdir calls in dash that may lead to spurious EOVERFLOW errors on 32-bit platforms. This patch changes them (as well as open(2)) to use the explicit large file API. Reported-by: Tatsuki Sugiura Signed-off-by: Herbert Xu diff --git a/configure.ac b/configure.ac

Re: [v2 PATCH] mktokens relative TMPDIR

2020-04-29 Thread Herbert Xu
wise it could result in unnecessary pattern expansion (e.g., someone does TMPDIR=/*/*/*). Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] Remove poplocalvars() always-zero argument, make it static

2020-04-28 Thread Herbert Xu
On Wed, Feb 19, 2020 at 05:39:13PM +0100, Denys Vlasenko wrote: > Signed-off-by: Denys Vlasenko > --- > src/var.c | 24 > src/var.h | 1 - > 2 files changed, 4 insertions(+), 21 deletions(-) Patch applied. Thanks. -- Email: Herbert Xu

Re: [PATCH] Rename DOWAIT_NORMAL to DOWAIT_NONBLOCK

2020-04-28 Thread Herbert Xu
On Wed, Feb 19, 2020 at 11:30:08AM +0100, Denys Vlasenko wrote: > To make it clearer what it is doing: nonblocking wait() > > Signed-off-by: Denys Vlasenko > --- > src/jobs.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) Patch applied. Thanks. -- Email

Re: [PATCH] mktokens relative TMPDIR

2020-04-28 Thread Herbert Xu
, > default to /tmp. > > The mkbuiltins script was already hardened to work relative to TMPDIR, > also defaulting to /tmp. > > Signed-off-by: Michael Greenberg Please make sure TMPDIR is quoted. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP

[PATCH] parser: Fix alias expansion after heredoc or newlines

2020-04-28 Thread Herbert Xu
hen it should, dash currently gets it wrong in every case. This patch fixes it by saving checkkwd and zeroing it where needed. Suggested-by: Harald van Dijk Reported-by: Harald van Dijk Reported-by: Martijn Dekker Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 5c9e9a

Re: [PATCH] dash: Fix stack overflow from infinite recursion in script

2019-07-21 Thread Herbert Xu
ust wrong. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Superseded patch?

2019-06-11 Thread Herbert Xu
se? Should I resubmit the patch? It means that the patch in question has been superseded by another one, namely: https://patchwork.kernel.org/patch/10263979/ Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: GCC format-security fixes

2019-05-28 Thread Herbert Xu
> again. I guess it just got lost? How about a resend? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

parser: Only accept single-digit parameter expansion outside of braces

2019-05-26 Thread Herbert Xu
bash ./test.sh one two three four five six seven eight nine ten > one0 This patch should fix the problem. Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index 1f9e8ec..2f14bf3 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1268,7 +1268,7 @@ varname:

parser: Fix old-style command substitution here-document crash

2019-03-28 Thread Herbert Xu
9 in openhere > ==39623==ABORTING > > This bug can be reproduced by running "dash < min" where min is þhe file > attached. I was able to reproduce this bug with the current git version > and the current debian version. > > cheers > project-repo > > < `&l

Re: -e not ignored in substition under tests

2019-03-28 Thread Herbert Xu
On Fri, Jun 22, 2018 at 10:41:43PM +0800, Herbert Xu wrote: > Benedikt Becker wrote: > > Hi, > > > > Dash does not ignore the -e option in substitutions $(...) under AND/OR > > lists and conditions. For example, in the program > > > >     set -e > >

[v2 PATCH] eval: Reset handler when entering a subshell

2019-03-03 Thread Herbert Xu
and. This patch fixes it by resetting the handler when entering a subshell. Reported-by: Martijn Dekker Signed-off-by: Herbert Xu diff --git a/src/eval.c b/src/eval.c index 1aad31a..6ee2e1a 100644 --- a/src/eval.c +++ b/src/eval.c @@ -41,6 +41,7 @@ * Evaluate a command. */ +#include "

[PATCH] shell: Reset handler when entering a subshell

2019-02-27 Thread Herbert Xu
foobar ) && echo WOOPS > > EOF > src/dash: 1: set: Illegal option -o foobar > $ echo end > end > $ > WOOPS > $ > > This was introduced by > > commit 46d5a7fcea81b489819f753451c1ad2fe435f148 > Author: Herbert Xu > Date: Tue Mar

[PATCH] expand: Fix double-decrement in argstr

2019-02-24 Thread Herbert Xu
n Dekker Fixes: 3cd538634f71 ("expand: Do not reprocess data when...") Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index af9cac9..e57efa6 100644 --- a/src/expand.c +++ b/src/expand.c @@ -285,7 +285,7 @@ start: q = stnputs(p, length, expdest);

Re: [PATCH 1/2] shell: Fix clang warnings about "string plus integer"

2019-02-24 Thread Herbert Xu
being increased is the address which points to the start of the string > in order to skip the initial character when some conditions are met. > > Signed-off-by: Antonio Ospite > --- > src/eval.c | 3 ++- > src/jobs.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) All applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH] options: Do not set commandname in procargs

2019-02-24 Thread Herbert Xu
port! How about this patch? ---8<--- We set commandname in procargs when we don't have to. This results in a duplicated output of arg0 when an error occurs. Reported-by: Olivier Duclos Signed-off-by: Herbert Xu diff --git a/src/options.c b/src/options.c index 6f381e6..a46c23b 100644 ---

[PATCH v4] redir: Handle nested exec within REALLY_CLOSED redirection

2019-01-17 Thread Herbert Xu
On Thu, Jan 17, 2019 at 11:07:23PM +0100, Martijn Dekker wrote: > Op 16-01-19 om 14:32 schreef Herbert Xu: > > So I'm going to go for a more complicated fix: > > The v3 patch introduces a bug: > > begin test script > init() { > exec 8 } >&

Re: [PATCH v3] redir: Handle nested exec within REALLY_CLOSED redirection

2019-01-16 Thread Herbert Xu
at fd 8 was closed to start with (because the first dup returned -1 on it). Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[PATCH v3] redir: Handle nested exec within REALLY_CLOSED redirection

2019-01-16 Thread Herbert Xu
t;[REDIR] Fix redirect restore on saved file...") Signed-off-by: Herbert Xu diff --git a/src/redir.c b/src/redir.c index e67cc0a..4f84a80 100644 --- a/src/redir.c +++ b/src/redir.c @@ -128,12 +128,12 @@ redirect(union node *redir, int flags) p = &sv->renamed[

Re: [v2 PATCH] eval: Only restore exit status on exit/return

2018-12-14 Thread Herbert Xu
tstatus if > necessary. returncmd itself doesn't jump up but it may be part of a subshell which would execute a jump to the top as part of the EV_EXIT optimisation. That's where you'd need to restore the exit status. Cheers, -- Email: Herbert Xu Home Page: http://gon

Re: [v2 PATCH] eval: Only restore exit status on exit/return

2018-12-14 Thread Herbert Xu
On Fri, Dec 14, 2018 at 08:02:04AM +, Harald van Dijk wrote: > On 14/12/2018 03:10, Herbert Xu wrote: > > > The reason this is needed is to support a naked return. With > > your patch a naked return would either have to always return the > > saved status or the new s

Re: [PATCH] eval: make traps work when "set -e" is enabled

2018-12-13 Thread Herbert Xu
t;set -e" is active, > but in case it isn't it would stll be good to behave like other shells. > > Any comment is welcome. > > Thank you, > Antonio > > > [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779416 > > > src/eval.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) 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: [PATCH 0/5] Build system updates and gcc warnings fixes

2018-12-13 Thread Herbert Xu
ompiler warning about missing parentheses > > .gitignore | 2 ++ > configure.ac| 8 +--- > src/Makefile.am | 16 > src/eval.c | 2 +- > src/system.h| 4 > 5 files changed, 16 insertions(+), 16 deletions(-) Patches 1, 2 and 5 applied.

[v3 PATCH] eval: Only restore exit status on exit/return

2018-12-13 Thread Herbert Xu
Herbert Xu wrote: > > Here is a new patch that fixes the reported issue for both signal > traps and the EXIT trap. This introduced a warning in trap.c. Here is an update to silence the warning. ---8<--- We unconditionally restore the saved status in exitreset, which is incorrec

[v2 PATCH] eval: avoid leaking memory associated with redirections

2018-12-13 Thread Herbert Xu
while true; do { true; } https://bugs.busybox.net/show_bug.cgi?id=7748 Signed-off-by: Ron Yorston I have simplified evaltree so that it simply sets the stack mark unconditionally. This allows us to remove the stack marks in the functions called by evaltree. Signed-off-by: Herbert Xu diff --gi

Re: [PATCH] Make mktokens accept a random TMPDIR, replace `...` with $(...).

2018-12-13 Thread Herbert Xu
mit this patch under its own Subject. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] Use a real non-cryptographic hash algorithm

2018-12-13 Thread Herbert Xu
lacement isn't up to stratch either. For real security, you'd need a strong algorithm and periodic rehashing. If it's hash collisions with a real-world script, please provide an example. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] var: ensure variables are fully initialised when unset

2018-12-13 Thread Herbert Xu
a new Subject line? patchwork is no longer picking up patches posted as a reply. Please also add a Signed-off-by tag. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [v2 PATCH] eval: Only restore exit status on exit/return

2018-12-13 Thread Herbert Xu
receding the trap action" is `false`, but inside the INT handler, it's > either `true` or `kill -s INT $$` (I think the latter, but it doesn't > matter). dash treats it as if it were still `false`. I think this makes sense. The EXIT trap trumps whatever happens inside it. FW

Re: [v2 PATCH] eval: Only restore exit status on exit/return

2018-12-13 Thread Herbert Xu
ther of which is what we want. Please refer to commit 70c16dd30d4cf824aa895e9f6c095fec741c65a8 Author: Herbert Xu Date: Mon Oct 6 21:51:26 2014 +0800 [BUILTIN] Return without arguments in a trap should use status outside traps Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] clear_traps: reset savestatus

2018-12-02 Thread Herbert Xu
so prints "exit" in ksh, mksh, posh, and bosh. I'm happy to allow exit traps to be processed here. But we should be able to achieve the same result without jumping back to main, by simply jumping back to the start of exitshell instead. Thanks, -- Email: Herbert Xu Home P

Re: eval: Only restore exit status on exit/return

2018-12-02 Thread Herbert Xu
not going to change existing behaviour unless it is clearly wrong. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[v2 PATCH] eval: Only restore exit status on exit/return

2018-12-02 Thread Herbert Xu
On Sat, Dec 01, 2018 at 04:45:39PM +0800, Herbert Xu wrote: > > Hmm, I think this breaks the following case which used to work: > > dash -c 'trap "(:; exit) && echo BUG" EXIT; false' > > I know this makes no sense but almost every other shell

Re: eval: Only restore exit status on exit/return

2018-12-01 Thread Herbert Xu
(void) > } > } > trapcnt = 0; > + savestatus = -1; > INTON; > } Hmm, I think this breaks the following case which used to work: dash -c 'trap "(:; exit) && echo BUG" EXIT; false' I know this makes no sense but almost every

Re: eval: Only restore exit status on exit/return

2018-11-29 Thread Herbert Xu
On Thu, Nov 29, 2018 at 03:27:31PM +0100, Martijn Dekker wrote: > Op 29-11-18 om 12:33 schreef Herbert Xu: > > Thanks for the report. This patch should fix the problem: > > Doesn't work for me, in fact it seems to make no difference. > > Here are a few more test cases.

eval: Only restore exit status on exit/return

2018-11-29 Thread Herbert Xu
T' > 1 Thanks for the report. This patch should fix the problem: ---8<--- We unconditionally restore the saved status in exitreset, which is incorrect as we only want to do it for exitcmd and returncmd. This patch fixes the problem by introducing EXEND. Reported-by: Martijn Dekker Fixes

Re: [PATCH 0/5] Build system updates and gcc warnings fixes

2018-11-28 Thread Herbert Xu
Antonio Ospite wrote: > > can I mark 3/5 as Superseded in patchwork myself? > Or would that disrupt your workflow? > > The intent would be to have one patch less for you to worry about. I just marked it. Thanks! -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~h

Re: [BUG] ${#v} aborts string processing

2018-11-27 Thread Herbert Xu
ps://patchwork.kernel.org/patch/10688471/ I will push it out soon. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[v2 PATCH] system: Disable glibc warning on sigsetmask

2018-11-20 Thread Herbert Xu
glibc this patch adds the pragmas to disable the warning in gcc around our one and only use of sigsetmask. It also disables it completely for non-gcc compilers and older gcc compilers as they may generate a warning too. Reported-by: Antonio Ospite Signed-off-by: Herbert Xu diff --git a/src/syst

Re: [PATCH] parser: preserve characters on heap in backquote parsing

2018-11-19 Thread Herbert Xu
s to fix it in just one spot because you could easily craft another script to exceed the size limit in any of the other places where we use alloca. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

eval: Use sh_warnx instead of warnx

2018-11-19 Thread Herbert Xu
flushall(); if (outerr(out1)) - warnx("%s: I/O error", commandname); + sh_warnx("%s: I/O error", commandname); status |= outerr(out1); exitstatus = status; cmddone: -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: [PATCH] parser: preserve characters on heap in backquote parsing

2018-11-19 Thread Herbert Xu
ccept this patch as alloca makes things a lot simpler in some cases. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

system: Disable gcc warning on sigsetmask

2018-11-19 Thread Herbert Xu
orm. Thanks! ---8<--- As sigsetmask is set as deprecated in glibc this patch adds the pragmas to disable the warning in gcc around our one and only use of sigsetmask. Reported-by: Antonio Ospite Signed-off-by: Herbert Xu diff --git a/src/system.h b/src/system.h index a8d09b3..f3aa930 100644 ---

parser: Do not push token back before parseheredoc

2018-11-19 Thread Herbert Xu
uot;[SHELL] Optimize dash -c "command" to avoid a fork") Signed-off-by: Herbert Xu diff --git a/src/parser.c b/src/parser.c index c4e6378..1f9e8ec 100644 --- a/src/parser.c +++ b/src/parser.c @@ -166,7 +166,7 @@ list(int nlflag) n1 = NULL; f

[PATCH] expand: Eat closing brace for length parameter expansion

2018-11-19 Thread Herbert Xu
one that belongs to a parameter expansion at the outer level. This patch fixes it. Reported-by: Martijn Dekker Fixes: 3cd538634f71 ("expand: Do not reprocess data when...") Signed-off-by: Herbert Xu diff --git a/src/expand.c b/src/expand.c index 856b7a9..af9cac9 100644 --- a/src/expand.c

Re: [PATCH] Add the seq builtin and improve some things in printf.c

2018-11-19 Thread Herbert Xu
ept a constant string without any > ugly casting. > > Signed-off-by: Devin Hussey Sorry, I'm not adding this builtin to dash as this conflicts with the goal of dash trying to be minimal. Perhaps bash or mksh would be a better option? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Re: Command substitution in here-documents

2018-11-19 Thread Herbert Xu
On Fri, Aug 17, 2018 at 09:08:35PM +0800, Herbert Xu wrote: > Ron Yorston wrote: > > I've been continuing to worry about this. > > > > In the old code (prior to commit 7c245aa) the TNL token that was > > detected in list() had actually been read. The

eval: Use the correct expansion mode for fd redirection

2018-11-19 Thread Herbert Xu
e the same expansions as done on a normal redirection. Reported-by: Andrej Shadura Signed-off-by: Herbert Xu diff --git a/src/eval.c b/src/eval.c index 6185db4..328fde3 100644 --- a/src/eval.c +++ b/src/eval.c @@ -529,7 +529,7 @@ expredir(union node *n) case NFROMFD:

  1   2   3   4   5   6   >