With the command sh setup.sh
, you instruct the dash
shell to interpret the script. The dash
shell is the system wide default shell in Ubuntu, whereas the more "heavy" (and bash developpers themselves even say "bloated" bash
shell is used for interactive shells (your prompt at the terminal).
dash
is light and more minimal, and does not support all features of bash
. That includes bracket expansion. If you want to use bash specific features in your script, then load it with bash:
bash setup.sh
If you make the script executable, then the shebang line is what you use to indicate which interpreter should run the script. This is a very first line in a script, included as a comment:
#!/bin/bash
If the script is made executable, then run by typing its name (/path/to/setup.sh
or ./setup.sh
if the script is in the current directory, or just setup.sh
if the script is in the PATH searched by the system for executable), this directive will tell it to be run with bash
.
The shebang line will not be honored if you start the script as an argument to the interpreter. Thus, even if the shebang line would be there, sh setup.sh
will still be using dash
rather than bash
.