aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-04-11 06:10:18 -0500
committerRob Landley <rob@landley.net>2021-04-11 06:10:18 -0500
commit2d690ed7f534e19de1b113afe8d8378363849a36 (patch)
treeaa700db6e869cb9aaab3519d6b9f8b14910da088
parent554565b70def39c39716ed495cafccb262a6af9a (diff)
downloadtoybox-2d690ed7f534e19de1b113afe8d8378363849a36.tar.gz
toysh: save _resolved_ variable contents in $IFS cache.
-rw-r--r--toys/pending/sh.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index e26d2791..0ccaa792 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -2314,12 +2314,14 @@ static struct sh_process *run_command(void)
if (!(sss = expand_one_arg(s, SEMI_IFS, persist ? 0 : &delete))) {
if (!pp) pp = xzalloc(sizeof(*pp));
pp->exit = 1;
- } else if (persist || sss != s) {
- vv->flags &= ~VAR_NOFREE;
- vv->str = sss==s ? xstrdup(sss) : sss;
+ } else {
+ if (persist || sss != s) {
+ vv->flags &= ~VAR_NOFREE;
+ vv->str = sss==s ? xstrdup(sss) : sss;
+ }
+ if (!strncmp(vv->str, "IFS=", 4))
+ do ff->ifs = vv->str+4; while ((ff = ff->next) != TT.ff->prev);
}
- if (!strncmp(vv->str, "IFS=", 4))
- do ff->ifs = s+4; while ((ff = ff->next) != TT.ff->prev);
}
}