From 07eb2040e85c1ae58e2e3ae222ac631fffd8683f Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 19 May 2021 06:13:16 +0200 Subject: [PATCH] Add regression test (re: e5e1d4b5) --- src/cmd/ksh93/tests/variables.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/ksh93/tests/variables.sh b/src/cmd/ksh93/tests/variables.sh index 253f84ad0..45aa0895c 100755 --- a/src/cmd/ksh93/tests/variables.sh +++ b/src/cmd/ksh93/tests/variables.sh @@ -1364,5 +1364,12 @@ EOF . $tmp/foo.sh > /dev/null [[ ${.sh.file} == $0 ]] || err_exit "\${.sh.file} is not set to the correct value after sourcing a file" +# ====== +# SHLVL should be decreased before exec'ing a program +exp=$((SHLVL+1))$'\n'$((SHLVL+2))$'\n'$((SHLVL+1)) +got=$("$SHELL" -c 'echo $SHLVL; "$SHELL" -c "echo \$SHLVL"; exec "$SHELL" -c "echo \$SHLVL"') +[[ $got == "$exp" ]] || err_exit "SHLVL not increased correctly" \ + "(expected $(printf %q "$exp"), got $(printf %q "$got"))" + # ====== exit $((Errors<125?Errors:125))