diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2014-11-02 15:29:06 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2014-11-02 15:29:06 +0000 |
commit | 023c2236e1280ad1539a2885c6479d0b89d6dc46 (patch) | |
tree | 9552f1a2c6e55fab593ef94749d233cbf640205d /Src | |
parent | 6a29f66f8a96cb7f41d472a2f7c80f75ea9eb92b (diff) | |
download | zsh-023c2236e1280ad1539a2885c6479d0b89d6dc46.tar.gz zsh-023c2236e1280ad1539a2885c6479d0b89d6dc46.tar.xz zsh-023c2236e1280ad1539a2885c6479d0b89d6dc46.zip |
Treat exec from subshell as if forked
This removes weird behaviour when optimising the last command. In particular SHLVL is correct from a subshell executed as the last command.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Src/exec.c b/Src/exec.c index 5bbd4e15d..d2d4e800b 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2995,6 +2995,15 @@ execcmd(Estate state, int input, int output, int how, int last1) * Note that any form of exec means that the subshell is fake * * (but we may be in a subshell already). */ is_exec = 1; + /* + * If we are in a subshell environment anyway, say we're forked, + * even if we're actually not forked because we know the + * subshell is exiting. This ensures SHLVL reflects the current + * shell, and also optimises out any save/restore we'd need to + * do if we were returning to the main shell. + */ + if (type == WC_SUBSH) + forked = 1; } if ((esglob = !(cflags & BINF_NOGLOB)) && args && htok) { |