Skip to content

Commit c2e0fda

Browse files
committed
ci: set -u in cirrus.sh to treat unset variables as an error
1 parent 44916ae commit c2e0fda

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.cirrus.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
env:
22
### compiler options
33
HOST:
4+
WRAPPER_CMD:
45
# Specific warnings can be disabled with -Wno-error=foo.
56
# -pedantic-errors is not equivalent to -Werror=pedantic and thus not implied by -Werror according to the GCC manual.
67
WERROR_CFLAGS: -Werror -pedantic-errors

ci/cirrus.sh

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

3-
set -e
4-
set -x
3+
set -eux
54

65
export LC_ALL=C
76

@@ -11,14 +10,20 @@ print_environment() {
1110
set +x
1211
# There are many ways to print variable names and their content. This one
1312
# does not rely on bash.
14-
for i in WERROR_CFLAGS MAKEFLAGS BUILD \
13+
for var in WERROR_CFLAGS MAKEFLAGS BUILD \
1514
ECMULTWINDOW ECMULTGENPRECISION ASM WIDEMUL WITH_VALGRIND EXTRAFLAGS \
1615
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG \
1716
SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETEST\
1817
EXAMPLES \
19-
WRAPPER_CMD CC AR NM HOST
18+
HOST WRAPPER_CMD \
19+
CC AR NM
2020
do
21-
eval 'printf "%s %s " "$i=\"${'"$i"'}\""'
21+
eval "isset=\${$var+x}"
22+
if [ -n "$isset" ]; then
23+
eval "val=\${$var}"
24+
# shellcheck disable=SC2154
25+
printf '%s="%s" ' "$var" "$val"
26+
fi
2227
done
2328
echo "$0"
2429
set -x
@@ -36,7 +41,7 @@ esac
3641

3742
env >> test_env.log
3843

39-
if [ -n "$CC" ]; then
44+
if [ -n "${CC+x}" ]; then
4045
# The MSVC compiler "cl" doesn't understand "-v"
4146
$CC -v || true
4247
fi

0 commit comments

Comments
 (0)