In bash, when I run the following command:
sh -c \"command\"
is there created a subshell and then the command
sh will spawn a subshell. But the subshell id stays the same
21934 pts/0 Ss 0:00 -bash
21963 pts/0 S 0:00 \_ /usr/bin/sudo -u root -H /bin/bash -c export AUDITUSER=ch002854; cd $HOME && exec -a '-bash' /bin/bash
22031 pts/0 S 0:00 \_ -bash
2969 pts/0 S 0:00 \_ sleep 1000
2993 pts/0 S 0:00 \_ sleep 1000
3726 pts/0 R+ 0:00 \_ ps af
With sh -c it will just run the command. This will reinitialize your environment variables and therefore it resets $BASH_SUBSHELL to its default 0.
# sh -c 'echo $BASHPID, $BASH_SUBSHELL'
12671, 0
While with `` or () you can create a subshell
# (echo $BASHPID, $BASH_SUBSHELL)
13214, 1