aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 02:46:56 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 02:46:56 +0200
commit0aaaa50b4551ab5912ccd95d66d633844eac6d85 (patch)
tree1a1f9e34c690051a678fb048064e4e98cca3536b /shell/ash.c
parent42eeb255c1c5f35373d3e7bfa892e4f864cf1266 (diff)
downloadbusybox-w32-0aaaa50b4551ab5912ccd95d66d633844eac6d85.tar.gz
busybox-w32-0aaaa50b4551ab5912ccd95d66d633844eac6d85.tar.bz2
busybox-w32-0aaaa50b4551ab5912ccd95d66d633844eac6d85.zip
ash: expand: Fixed "$@" expansion when EXP_FULL is false
Upstream commit: Date: Thu, 1 Jan 2015 07:53:10 +1100 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> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 731c4b2b0..4f6ba0c70 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6615,7 +6615,10 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list, int
6615 int subtype = varflags & VSTYPE; 6615 int subtype = varflags & VSTYPE;
6616 int discard = subtype == VSPLUS || subtype == VSLENGTH; 6616 int discard = subtype == VSPLUS || subtype == VSLENGTH;
6617 int quotes = (discard ? 0 : (flags & QUOTES_ESC)) | QUOTES_KEEPNUL; 6617 int quotes = (discard ? 0 : (flags & QUOTES_ESC)) | QUOTES_KEEPNUL;
6618 int syntax = quoted ? DQSYNTAX : BASESYNTAX; 6618 int syntax;
6619
6620 sep = (flags & EXP_FULL) << CHAR_BIT;
6621 syntax = quoted ? DQSYNTAX : BASESYNTAX;
6619 6622
6620 switch (*name) { 6623 switch (*name) {
6621 case '$': 6624 case '$':
@@ -6649,23 +6652,18 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list, int
6649 raise_error_syntax("bad substitution"); 6652 raise_error_syntax("bad substitution");
6650#endif 6653#endif
6651 break; 6654 break;
6652 case '@': { 6655 case '@':
6656 if (quoted && sep)
6657 goto param;
6658 /* fall through */
6659 case '*': {
6653 char **ap; 6660 char **ap;
6654 char sepc; 6661 char sepc;
6655 6662
6656 sep = 0; 6663 if (quoted)
6657 if (quoted && (flags & EXP_FULL)) { 6664 sep = 0;
6658 /* note: this is not meant as PEOF value */ 6665 sep |= ifsset() ? ifsval()[0] : ' ';
6659 sep = 1 << CHAR_BIT;
6660 goto param;
6661 }
6662 /* fall through */
6663 case '*':
6664 sep = ifsset() ? (unsigned char)(ifsval()[0]) : ' ';
6665 if (!quoted) {
6666 param: 6666 param:
6667 sep |= (flags & EXP_FULL) << CHAR_BIT;
6668 }
6669 sepc = sep; 6667 sepc = sep;
6670 *quotedp = !sepc; 6668 *quotedp = !sepc;
6671 ap = shellparam.p; 6669 ap = shellparam.p;
@@ -6680,7 +6678,7 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list, int
6680 } 6678 }
6681 } 6679 }
6682 break; 6680 break;
6683 } /* case '@' and '*' */ 6681 } /* case '*' */
6684 case '0': 6682 case '0':
6685 case '1': 6683 case '1':
6686 case '2': 6684 case '2':