From 2d690ed7f534e19de1b113afe8d8378363849a36 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 11 Apr 2021 06:10:18 -0500 Subject: toysh: save _resolved_ variable contents in $IFS cache. --- toys/pending/sh.c | 12 +++++++----- 1 file 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); } } -- cgit v1.2.3