mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-28 17:10:59 +01:00
39125: More care needed decrementing SHLVL on exec.
Not needed in subshell.
This commit is contained in:
parent
70166178bd
commit
8ce98c75f5
3 changed files with 30 additions and 4 deletions
|
|
@ -1,3 +1,8 @@
|
|||
2016-08-31 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* Stephane: 39125: Src/exec.c, Test/D04parameter.ztst: More care
|
||||
decrementing SHLVL on exec; not needed in subshells.
|
||||
|
||||
2016-08-31 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 39122: Completion/Unix/Command/_git: __git_recent_branches:
|
||||
|
|
|
|||
|
|
@ -3694,12 +3694,15 @@ execcmd(Estate state, int input, int output, int how, int last1)
|
|||
restore_params(restorelist, removelist);
|
||||
|
||||
} else {
|
||||
if (!subsh) {
|
||||
/* for either implicit or explicit "exec", decrease $SHLVL
|
||||
* as we're now done as a shell */
|
||||
if (!forked)
|
||||
setiparam("SHLVL", --shlvl);
|
||||
if (do_exec) {
|
||||
|
||||
/* If we are exec'ing a command, and we are not *
|
||||
* in a subshell, then save the history file. */
|
||||
if (!subsh && isset(RCS) && interact && !nohistsave)
|
||||
if (do_exec && isset(RCS) && interact && !nohistsave)
|
||||
savehistfile(NULL, 1, HFILE_USE_OPTIONS);
|
||||
}
|
||||
if (type == WC_SIMPLE || type == WC_TYPESET) {
|
||||
|
|
|
|||
|
|
@ -1716,6 +1716,24 @@
|
|||
$ZTST_testdir/../Src/zsh -fc '(echo $SHLVL)'
|
||||
0:SHLVL appears sensible when about to exit shell
|
||||
>2
|
||||
>2
|
||||
|
||||
SHLVL=1
|
||||
$ZTST_testdir/../Src/zsh -fc 'sh -c "echo \$SHLVL"'
|
||||
$ZTST_testdir/../Src/zsh -fc '(sh -c "echo \$SHLVL")'
|
||||
$ZTST_testdir/../Src/zsh -fc '( (sh -c "echo \$SHLVL"))'
|
||||
0:SHLVL decremented upon implicit exec optimisation
|
||||
>1
|
||||
>1
|
||||
>1
|
||||
|
||||
SHLVL=1
|
||||
$ZTST_testdir/../Src/zsh -fc '(sh -c "echo \$SHLVL"); exit'
|
||||
$ZTST_testdir/../Src/zsh -fc '(exec sh -c "echo \$SHLVL"); exit'
|
||||
$ZTST_testdir/../Src/zsh -fc '( (sh -c "echo \$SHLVL"); exit)'
|
||||
0:SHLVL not decremented upon exec in subshells
|
||||
>2
|
||||
>2
|
||||
>2
|
||||
|
||||
# The following tests the return behaviour of parsestr/parsestrnoerr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue