Skip to content

Commit 1ebed39

Browse files
committed
Add set -o errexit -o nounset to shell scripts
For #33604
1 parent 2663148 commit 1ebed39

File tree

9 files changed

+24
-5
lines changed

9 files changed

+24
-5
lines changed

scripts/git/pre-commit.git-hook

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ workdir=$(git rev-parse --show-toplevel)
1010

1111
cd "$workdir" || exit 1
1212

13-
set -e
13+
set -o errexit
14+
set -o nounset
1415

1516
if [ -e tests/shellcheck-tests.sh ]; then
1617
tests/shellcheck-tests.sh

tests/shellcheck-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

3-
# Exit on errors
4-
set -e
3+
set -o errexit
4+
set -o nounset
55

66
# SC1117 was disabled after 0.5, because it was too pedantic
77
EXCLUSIONS="--exclude=SC1117"

tests/unit-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

3-
# Exit on errors
4-
set -e
3+
set -o errexit
4+
set -o nounset
55

66
# Output is prefixed with the name of the script
77
myname=$(basename "$0")

tools/bootstrap-network.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# network-flavour: one of the files in the networks directory,
1313
# (default: 'bridges+hs-v23')
1414

15+
set -o errexit
16+
set -o nounset
17+
1518
# Get a working chutney path
1619
if [ ! -d "$CHUTNEY_PATH" ] || [ ! -x "$CHUTNEY_PATH/chutney" ]; then
1720
# looks like a broken path: use the path to this tool instead

tools/diagnostics.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# tools/diagnostics.sh
1818
# tools/diagnostics.sh 001a
1919

20+
set -o errexit
21+
set -o nounset
22+
2023
if [ ! -d "$CHUTNEY_PATH" ] || [ ! -x "$CHUTNEY_PATH/chutney" ]; then
2124
# looks like a broken path: use the path to this tool instead
2225
TOOLS_PATH=$(dirname "$0")

tools/hsaddress.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# Examples: tools/hsaddress.sh
88
# tools/hsaddress.sh 025h
99

10+
set -o errexit
11+
set -o nounset
12+
1013
if [ ! -d "$CHUTNEY_PATH" ] || [ ! -x "$CHUTNEY_PATH/chutney" ]; then
1114
# looks like a broken path: use the path to this tool instead
1215
TOOLS_PATH=$(dirname "$0")

tools/test-network-impl.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh
22

3+
set -o errexit
4+
set -o nounset
5+
36
if ! "$CHUTNEY_PATH/tools/bootstrap-network.sh" "$NETWORK_FLAVOUR"; then
47
if test "$?" = 77; then
58
$ECHO "SKIP: $NETWORK_FLAVOUR not supported."

tools/test-network.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh
22

3+
set -o errexit
4+
set -o nounset
5+
36
export ECHO="${ECHO:-echo}"
47

58
# Output is prefixed with the name of the script

tools/warnings.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
# CHUTNEY_WARNINGS_SKIP:
2626
# set to "true" to skip all warnings
2727

28+
set -o errexit
29+
set -o nounset
30+
2831
if [ "$CHUTNEY_WARNINGS_SKIP" = true ]; then
2932
exit 0
3033
fi

0 commit comments

Comments
 (0)