Skip to contentSkip to conversation

Fixed "$@" expansion when EXP_FULL is false

EXPAND Herbert Xu 1 participant 1 message Dec 31, 2014 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Herbert Xu

author
#1 lore raw
Quoted 12 lines · Juergen Daubert

Hi,

today I tried to use dash from git as /bin/sh and run in a lot of problem I don't see with stable version 0.5.8.
After some investigations I narrowed it down to commit

3c06acdac0b1ba0e0acdda513a57ee6e31385dce
[EXPAND] Split unquoted $@/$* correctly when IFS is set but empty

and related following to expand.c

Quoted 6 lines

It seems that the changes to dash triggers, among others, some problem with libtool.

As examples I've attached build logs for libpixman and kbd, there are a lot other builds that failed as well. If you need more, please let me know.

Thanks for the report. This patch should fix the problem.

-- >8 --
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.

src/expand.c +5 -6
index dfb3f0e..b2d710d 100644
@@ -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))

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt