Difference between revisions of "Explanation of bash -ex"
From MyWiki
(Created page with "<source lang="text"> Bash scripts can use various options on the shebang (#!/bin/bash). A more common one is: ‘#!/bin/bash -ex’. -e Exit immediately if a command exits wi...") |
|||
Line 2: | Line 2: | ||
Bash scripts can use various options on the shebang (#!/bin/bash). A more common one is: ‘#!/bin/bash -ex’. | Bash scripts can use various options on the shebang (#!/bin/bash). A more common one is: ‘#!/bin/bash -ex’. | ||
− | -e Exit immediately if a command exits with a non-zero status. -x Print commands and their arguments as they are executed. | + | -e Exit immediately if a command exits with a non-zero status. |
+ | -x Print commands and their arguments as they are executed. | ||
In short, adding -ex to your #!/bin/bash will give verbose output and also will abort your script immediately if part of the script fails. | In short, adding -ex to your #!/bin/bash will give verbose output and also will abort your script immediately if part of the script fails. | ||
</source> | </source> |
Latest revision as of 14:08, 28 August 2019
Bash scripts can use various options on the shebang (#!/bin/bash). A more common one is: ‘#!/bin/bash -ex’. -e Exit immediately if a command exits with a non-zero status. -x Print commands and their arguments as they are executed. In short, adding -ex to your #!/bin/bash will give verbose output and also will abort your script immediately if part of the script fails.