On Fri, 26 Aug 2022, Tim Woodall wrote:
$ cat Makefile.test
...
Many thanks everybody for all of the help understanding this. Not this exact issue but effectively the same was reported in bug #944780 and the unbound variable in /etc/bash.bashrc was reported in #941248 I've now submitted a patch to #944780 that I think fixes all of the cases where this fails, viz bash -c 'echo $SHLVL' & ( bash -c 'echo $SHLVL' ) $( bash -c 'echo $SHLVL' ) bash -c 'echo $SHLVL' | cat coproc bash -c 'echo $SHLVL' All of which incorrectly (IMO) fail to increment SHLVL I found this amusing case where I can decrement SHLVL below 1. I haven't managed to get it to go negative. $ echo $SHLVL 1 $ cat Makefile.test all: echo $$SHLVL $ make -f Makefile.test | cat echo $SHLVL 0 $ Tim.