diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-01-01 07:53:10 +1100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-03-28 21:42:54 +0000 |
commit | 57da2c169d4f22009725f47645ca6a4501f2475f (patch) | |
tree | aa1a28b232f5136d04f7d1cfcab70fa0ebe59a42 | |
parent | 9b271c8b259fff6930f58d2ea3346b0bdd5e66c2 (diff) | |
download | klibc-57da2c169d4f22009725f47645ca6a4501f2475f.tar.gz |
[klibc] dash: expand: Fixed "$@" expansion when EXP_FULL is false
[ dash commit bc4d989af4a4069f70f19fbe41a7d7ad61965ff8 ]
The commit 3c06acdac0b1ba0e0acdda513a57ee6e31385dce ([EXPAND]
Split unquoted $@/$* correctly when IFS is set but empty) broke
the case where $@ is in quotes and EXP_FULL is false.
In that case we should still emit IFS as field splitting is not
performed.
Reported-by: Juergen Daubert <jue@jue.li>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/dash/expand.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/usr/dash/expand.c b/usr/dash/expand.c index a2f99f1495b09..c04ff6e12f89c 100644 --- a/usr/dash/expand.c +++ b/usr/dash/expand.c @@ -901,6 +901,7 @@ varvalue(char *name, int varflags, int flags, int *quotedp) int quotes = (discard ? 0 : (flags & QUOTES_ESC)) | QUOTES_KEEPNUL; ssize_t len = 0; + sep = (flags & EXP_FULL) << CHAR_BIT; syntax = quoted ? DQSYNTAX : BASESYNTAX; switch (*name) { @@ -931,16 +932,14 @@ numvar: expdest = p; break; case '@': - sep = 0; - if (quoted) + if (quoted && sep) goto param; /* fall through */ case '*': - sep = ifsset() ? ifsval()[0] : ' '; - if (!quoted) { + if (quoted) + sep = 0; + sep |= ifsset() ? ifsval()[0] : ' '; param: - sep |= (flags & EXP_FULL) << CHAR_BIT; - } sepc = sep; *quotedp = !sepc; if (!(ap = shellparam.p)) |