summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-04-02 14:27:50 +0200
committerDenys Vlasenko2018-04-02 14:27:50 +0200
commit9a95df90463ee0eddc0585f0e5affa827701fdfb (patch)
tree38e0902751c50c55ad874499b4d4be6e7f53b45c /shell/ash.c
parent355ec353be14f33f69fe3e3992ab5a815b3a01a6 (diff)
downloadbusybox-9a95df90463ee0eddc0585f0e5affa827701fdfb.zip
busybox-9a95df90463ee0eddc0585f0e5affa827701fdfb.tar.gz
ash: expand: Fix bugs with words connected to the right of $@
Upstream email: This is actually composed of two bugs. First of all our tracking of quotemark is wrong so anything after "$@" becomes quoted. Once we fix that then the problem is that the first space character after "$@" is not recognised as an IFS. This patch fixes both. 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.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 35ea58f..d82eba1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5975,7 +5975,10 @@ ifsbreakup(char *string, struct arglist *arglist)
realifs = ifsset() ? ifsval() : defifs;
ifsp = &ifsfirst;
do {
+ int afternul;
+
p = string + ifsp->begoff;
+ afternul = nulonly;
nulonly = ifsp->nulonly;
ifs = nulonly ? nullstr : realifs;
ifsspc = 0;
@@ -5987,7 +5990,7 @@ ifsbreakup(char *string, struct arglist *arglist)
p++;
continue;
}
- if (!nulonly)
+ if (!(afternul || nulonly))
ifsspc = (strchr(defifs, *p) != NULL);
/* Ignore IFS whitespace at start */
if (q == start && ifsspc) {
@@ -6650,12 +6653,12 @@ argstr(char *p, int flags)
case CTLENDVAR: /* ??? */
goto breakloop;
case CTLQUOTEMARK:
- inquotes ^= EXP_QUOTED;
/* "$@" syntax adherence hack */
- if (inquotes && !memcmp(p, dolatstr + 1, DOLATSTRLEN - 1)) {
- p = evalvar(p + 1, flags | inquotes) + 1;
+ if (!inquotes && !memcmp(p, dolatstr + 1, DOLATSTRLEN - 1)) {
+ p = evalvar(p + 1, flags | EXP_QUOTED) + 1;
goto start;
}
+ inquotes ^= EXP_QUOTED;
addquote:
if (flags & QUOTES_ESC) {
p--;