There are many many shell scripts in the project, but most of them are in this repo.
Currently we are using checkResult $? from commons.sh to check last command result when we want to make sure it passes.
It's better to use set -euxo pipefail at the beginning of bash files to avoid silent issues, especially when running on these scripts on CI.
GitHub Workflows/Actions already use set to fail early.
-
set -e option instructs bash to immediately exit if any command has a non-zero exit status.
-
set -o pipefail option prevents errors in a pipeline from being masked. If any command in a pipeline fails, that return code will be used as the return code of the whole pipeline
-
set -x option enables a mode of the shell where all executed commands are printed to the terminal.
-
set -u option validate reference to any variable you haven't previously defined - with the exceptions of $* and $@ - is an error, and causes the program to immediately exit.
Tasks:
Links:
There are many many shell scripts in the project, but most of them are in this repo.
Currently we are using
checkResult $?from commons.sh to check last command result when we want to make sure it passes.It's better to use
set -euxo pipefailat the beginning of bash files to avoid silent issues, especially when running on these scripts on CI.GitHub Workflows/Actions already use
setto fail early.set -eoption instructs bash to immediately exit if any command has a non-zero exit status.set -o pipefailoption prevents errors in a pipeline from being masked. If any command in a pipeline fails, that return code will be used as the return code of the whole pipelineset -xoption enables a mode of the shell where all executed commands are printed to the terminal.set -uoption validate reference to any variable you haven't previously defined - with the exceptions ofTasks:
set -euxo pipefailafter#!/bin/bashcheckResult $?difforgit diff --exit-code... and other commands that exits with1for expected results, not errors)Links: