summary refs log tree commit diff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-01-01 07:53:10 +1100
committerHerbert Xu <herbert@gondor.apana.org.au>2015-01-05 22:58:52 +1100
commitbc4d989af4a4069f70f19fbe41a7d7ad61965ff8 (patch)
tree696403dfeb86d6b4cd6adb897367f861690603f5
parentbuiltin: create builtins.c properly on old cpp (diff)
downloaddash-bc4d989af4a4069f70f19fbe41a7d7ad61965ff8.tar.gz
dash-bc4d989af4a4069f70f19fbe41a7d7ad61965ff8.zip
expand: Fixed "$@" expansion when EXP_FULL is false
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>
-rw-r--r--src/expand.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/expand.c b/src/expand.c
index dfb3f0e..b2d710d 100644
--- a/src/expand.c
+++ b/src/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))