From 341b0b469ea62cd6a77c9b275ba3aa2483e3d3f9 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 12 Oct 2022 16:15:51 +0100 Subject: [PATCH] Make bash scripts exit on error rather than continue (#23467) --- scripts/fetch-develop.deps.sh | 2 +- scripts/genflags.sh | 2 ++ scripts/get-version-from-git.sh | 2 ++ scripts/layered.sh | 2 +- scripts/make-icons.sh | 3 +-- scripts/normalize-version.sh | 2 ++ 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/fetch-develop.deps.sh b/scripts/fetch-develop.deps.sh index 71850188a6..158cf85708 100755 --- a/scripts/fetch-develop.deps.sh +++ b/scripts/fetch-develop.deps.sh @@ -6,7 +6,7 @@ # the branch the current checkout is on, use that branch. Otherwise, # use develop. -set -ex +set -x GIT_CLONE_ARGS=("$@") [ -z "$defbranch" ] && defbranch="develop" diff --git a/scripts/genflags.sh b/scripts/genflags.sh index d960c6de0f..0d9a5f2b9e 100755 --- a/scripts/genflags.sh +++ b/scripts/genflags.sh @@ -25,6 +25,8 @@ # all phonenumber.js-supported country flags (as SVGs) into # PNGs that can be used by CountryDropdown.js. +set -e + # Allow CTRL+C to terminate the script trap "echo Exited!; exit;" SIGINT SIGTERM diff --git a/scripts/get-version-from-git.sh b/scripts/get-version-from-git.sh index eb9729c78e..bc08dd6774 100755 --- a/scripts/get-version-from-git.sh +++ b/scripts/get-version-from-git.sh @@ -3,6 +3,8 @@ # Echoes a version based on the git hashes of the element-web, react-sdk & js-sdk checkouts, for the case where # these dependencies are git checkouts. +set -e + # Since the deps are fetched from git, we can rev-parse REACT_SHA=$(git -C node_modules/matrix-react-sdk rev-parse --short=12 HEAD) JSSDK_SHA=$(git -C node_modules/matrix-js-sdk rev-parse --short=12 HEAD) diff --git a/scripts/layered.sh b/scripts/layered.sh index dc53b29aea..406022e88d 100755 --- a/scripts/layered.sh +++ b/scripts/layered.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -x +set -ex # Creates a layered environment with the full repo for the app and SDKs cloned # and linked. This gives an element-web dev environment ready to build with diff --git a/scripts/make-icons.sh b/scripts/make-icons.sh index 2db5293df3..f60806cbba 100755 --- a/scripts/make-icons.sh +++ b/scripts/make-icons.sh @@ -12,8 +12,7 @@ then exit fi -set -e -set -x +set -ex tmpdir=`mktemp -d 2>/dev/null || mktemp -d -t 'icontmp'` diff --git a/scripts/normalize-version.sh b/scripts/normalize-version.sh index d8a68bebd8..b090179aad 100755 --- a/scripts/normalize-version.sh +++ b/scripts/normalize-version.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + # If $1 looks like v1.2.3 or v1.2.3-foo, strip the leading v, then print it to stdout if [[ $1 =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-.+)?$ ]]; then echo ${1:1}