Skip to content

Commit 75d7b7f

Browse files
Merge bitcoin-core/secp256k1#1154: ci: set -u in cirrus.sh to treat unset variables as an error
7a74688 ci: add missing CFLAGS & CPPFLAGS variable to print_environment (Jonas Nick) c2e0fda ci: set -u in cirrus.sh to treat unset variables as an error (Jonas Nick) Pull request description: This PR is supposed to prevent accidental misuse of cirrus.sh. Maybe there is a way to check if `CC`, `AR` and `NM` are set within the loop that deals with the other variables, but so far I did not come up with one (that's POSIX shell compliant). ACKs for top commit: real-or-random: ACK 7a74688 hebasto: re-ACK 7a74688 Tree-SHA512: 91e42b3f1192fbf86e6fb43942713e78b2bee977ddd95256ea7448f84324369399d31ec4eedd47af595bf994bbc9396e26bb5c93bdb7f58c4310b5d3d5d66731
2 parents 9a8d65f + 7a74688 commit 75d7b7f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

.cirrus.yml

+1
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

+11-6
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 CFLAGS CPPFLAGS 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)