diff options
author | Peter Stephenson <pws@zsh.org> | 2015-04-15 09:44:19 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-04-15 09:44:19 +0100 |
commit | a2c579050fbf40eb9192f043e901e6b2eff3ab50 (patch) | |
tree | 320c38cb5e98627b020da1f1ca9be387641d7ee2 /Src | |
parent | 741b0bd97f6ddbd69fb2fa1dbbf6604a51488d82 (diff) | |
download | zsh-a2c579050fbf40eb9192f043e901e6b2eff3ab50.tar.gz zsh-a2c579050fbf40eb9192f043e901e6b2eff3ab50.tar.xz zsh-a2c579050fbf40eb9192f043e901e6b2eff3ab50.zip |
34887: Fix POSIX_BUILTINS with assignment.
In the form var=val command special-builtin-or-func the var is restored after execution, unlike the case where "command" is absent. Clear up case in code that handles this. Add tests.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Src/exec.c b/Src/exec.c index 1a6149ad7..2ee37d09f 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3384,14 +3384,28 @@ execcmd(Estate state, int input, int output, int how, int last1) LinkList restorelist = 0, removelist = 0; /* builtin or shell function */ - if (!forked && ((cflags & BINF_COMMAND) || - (unset(POSIXBUILTINS) && !assign) || - (isset(POSIXBUILTINS) && !is_shfunc && - !(hn->flags & BINF_PSPECIAL)))) { - if (varspc) + if (!forked && varspc) { + int do_save = 0; + if (isset(POSIXBUILTINS)) { + /* + * If it's a function or special builtin --- save + * if it's got "command" in front. + * If it's a normal command --- save. + */ + if (is_shfunc || (hn->flags & BINF_PSPECIAL)) + do_save = (orig_cflags & BINF_COMMAND); + else + do_save = 1; + } else { + /* + * Save if it's got "command" in front or it's + * not a magic-equals assignment. + */ + if ((cflags & BINF_COMMAND) || !assign) + do_save = 1; + } + if (do_save) save_params(state, varspc, &restorelist, &removelist); - else - restorelist = removelist = NULL; } if (varspc) { /* Export this if the command is a shell function, |