0

I know that $SHELL is an environment-variable, which refers to the current default-shell. echo $SHELL prints the path to stdout.

Here the use of it for keeping the terminal window open: How to run a script without closing the terminal?

What does $SHELL do, when it is entered like a some command?

1 Answer 1

0

It is expanded, and its content is interpreted as a command to run. For example, if it contains /bin/bash, it will run /bin/bash, i.e. it will start a new bash shell.

In the particular example, it prevents the terminal from being closed, as the shell is running in interactive mode, i.e. waiting for the user to type in commands.

2
  • Ah, okay. Basically, it opens another command prompt below. And that then keeps the terminal open, because waiting for an user-insertion?
    – st88
    Feb 7, 2020 at 9:30
  • Yes, exactly. When you exit the shell, the window will be closed.
    – choroba
    Feb 7, 2020 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.