How does bash <command-argument> work?

Hello Friends

About bash

For a new tty when is executed the echo $SHLVL command it displays 1 as expected. Now, if in the same tty is executed the bash command and later again the echo $SHLVL command it displays 2. Is mandatory use the exit command to exit of course. Furthermore I did do realize that each bash has its own history command and the user is interacting or has access in the current bash.

So far, after to did do a research it seems it is a kind of subshell (correct me if I am wrong), it because mostly a subshell is created through the (<command>) approach instead.

Just as playing I executed the bash cat /etc/os-release command and nothing is printed.

Therefore being curious

Question

  • How does bash <command-argument> work?

As extra question:

  • Under what circumstances the bash <command-argument> approach would be mandatory to be applied?

Every time you type bash, with or without a command, it forks another shell process, which is the child of the bash shell you are currently in.
If you look with ps you will see both the parent and child bash processes running.
An exit terminates the shell you are currently in.

2 Likes