server: build: make script safer by failing on pipes

The bash shell normally only looks at the exit code of the last command of a
pipeline. This behavior is not ideal as it causes the -e option to only be
able to act on the exit code of a pipeline’s last command. This is where -o
pipefail comes in. This particular option sets the exit code of a pipeline
to that of the rightmost command to exit with a non-zero status, or to zero if
all commands of the pipeline exit successfully.

See more about safer bash scripts:
https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This commit is contained in:
Luís Ferreira 2020-08-27 18:10:50 +01:00
parent 1cf59187be
commit f50d9dc23d
No known key found for this signature in database
GPG key ID: 730750D54B7A9F66

View file

@ -9,7 +9,7 @@
#
# BUILD_DIR=my_build_dir ./build_without_gradle.sh
set -e
set -eo pipefail
SCRCPY_DEBUG=false
SCRCPY_VERSION_NAME=1.16