From 940f264ee6b75e013658d4ba7f6a6dd77ae014d3 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Fri, 19 Sep 2014 17:31:34 -0700 Subject: 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. --- tests/test3.in | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/test3.in') 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 -- cgit v1.2.3