Reputation: 239
could you please explain to me what exactly this shell command do? It is quite difficoult to retrive the description of this -ex option.
sh #!/bin/bash -ex
Thanks in advance
Upvotes: 0
Views: 312
Reputation: 2505
It means you're invoking new bash shell with -e and -x shell options
See shell options here: https://tldp.org/LDP/abs/html/options.html
-e errexit Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
-x xtrace Similar to -v, but expands commands
since -x is similar to -v:
-v verbose Print each command to stdout before executing it
So it's actually dropping to next level shell:
$ echo $SHLVL
1
$ sh #!/bin/bash -ex
$ echo $SHLVL
2
in which in this level 2 shell, option -e and -x is activated
Upvotes: 2