about summary refs log tree commit diff
path: root/Test/D04parameter.ztst
diff options
context:
space:
mode:
authorStephane Chazelas <stephane.chazelas@gmail.com>2016-08-30 13:44:26 +0100
committerPeter Stephenson <pws@zsh.org>2016-08-31 10:21:00 +0100
commit8ce98c75f5330eecfa474e342146b8d057abcefc (patch)
treee6a98cc00046134c2e30c214a8a5282fe193a044 /Test/D04parameter.ztst
parent70166178bdc7ea149eb1cd29bcdb549a392c46dd (diff)
downloadzsh-8ce98c75f5330eecfa474e342146b8d057abcefc.tar.gz
zsh-8ce98c75f5330eecfa474e342146b8d057abcefc.tar.xz
zsh-8ce98c75f5330eecfa474e342146b8d057abcefc.zip
39125: More care needed decrementing SHLVL on exec.
Not needed in subshell.
Diffstat (limited to 'Test/D04parameter.ztst')
-rw-r--r--Test/D04parameter.ztst18
1 files changed, 18 insertions, 0 deletions
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 063007956..75ace5a9b 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1718,6 +1718,24 @@
 >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
   alias param-test-alias='print $'\''\x45xpanded in substitution'\' 
   param='$(param-test-alias)'