diff options
author | Kevin Ballard <kevin@sb.org> | 2014-09-19 17:31:34 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-09-19 17:38:54 -0700 |
commit | 940f264ee6b75e013658d4ba7f6a6dd77ae014d3 (patch) | |
tree | cb14835d78554378343c4464167062ff7a650823 /tests/test3.in | |
parent | 761be8ab7fb62965b8dc9dfd6ac6451cda578ad0 (diff) |
Decrement SHLVL when running `exec`
`exec` removes fish from the shell "stack", so SHLVL needs to be
decremented to match. This means `exec fish` will result in the same
SHLVL in the new fish instance.
Also tweak the SHLVL logic to interpret an environment SHLVL of "3foo"
as garbage instead of as the value "3".
Fixes #1693.
Diffstat (limited to 'tests/test3.in')
-rw-r--r-- | tests/test3.in | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test3.in b/tests/test3.in index 56cceeb5..b83b69c0 100644 --- a/tests/test3.in +++ b/tests/test3.in @@ -236,5 +236,12 @@ echo Missing: $testu # test SHLVL # use a subshell to ensure a clean slate env SHLVL= ../fish -c 'echo SHLVL: $SHLVL; ../fish -c \'echo SHLVL: $SHLVL\'' +# exec should decrement SHLVL +env SHLVL= ../fish -c 'echo SHLVL: $SHLVL; exec ../fish -c \'echo SHLVL: $SHLVL\'' +# garbage SHLVLs should be treated as garbage +env SHLVL=3foo ../fish -c 'echo SHLVL: $SHLVL' +# whitespace is allowed though (for bash compatibility) +env SHLVL="3 " ../fish -c 'echo SHLVL: $SHLVL' +env SHLVL=" 3" ../fish -c 'echo SHLVL: $SHLVL' true |