Skip to content

Commit 1eab3dc

Browse files
laanwjknst
authored andcommitted
Merge bitcoin#23462: test: Enable SC2046 and SC2086 shellcheck rules
fe0ff56 test: Enable SC2046 shellcheck rule (Hennadii Stepanov) 9a1ad7b test: Enable SC2086 shellcheck rule (Hennadii Stepanov) Pull request description: Closes bitcoin#20879. Replaces bitcoin#22695. **Note for reviewers**. Some touched shell scripts are not being run in CI, therefore they require more thorough reviewing: - `contrib/devtools/gen-manpages.sh` - `contrib/macdeploy/detached-sig-apply.sh` - `contrib/windeploy/detached-sig-create.sh` - `src/qt/res/animation/makespinner.sh` ACKs for top commit: laanwj: Code review re-ACK fe0ff56 Tree-SHA512: 73619b9a7bcb6cf0dfc4189a753ef550d40c82a3432bb9d8d8a994310d42594576038daac7e0c2fc004d716976bb1413b9a77848ecf088b25b69ed0773b77e8e
1 parent 92d78e3 commit 1eab3dc

File tree

9 files changed

+37
-35
lines changed

9 files changed

+37
-35
lines changed

ci/dash/build_depends.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ source ./ci/dash/matrix.sh
1414
unset CC; unset CXX
1515
unset DISPLAY
1616

17-
mkdir -p $CACHE_DIR/depends
18-
mkdir -p $CACHE_DIR/sdk-sources
17+
mkdir -p "$CACHE_DIR/depends"
18+
mkdir -p "$CACHE_DIR/sdk-sources"
1919

20-
ln -s $CACHE_DIR/depends ${DEPENDS_DIR}/built
21-
ln -s $CACHE_DIR/sdk-sources ${DEPENDS_DIR}/sdk-sources
20+
ln -s "$CACHE_DIR/depends" "${DEPENDS_DIR}/built"
21+
ln -s "$CACHE_DIR/sdk-sources" "${DEPENDS_DIR}/sdk-sources"
2222

2323
if [[ "${HOST}" == "x86_64-apple-darwin" ]]; then
2424
./contrib/containers/guix/scripts/setup-sdk
2525
fi
2626

27-
make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
27+
make "$MAKEJOBS" -C depends HOST="$HOST" "$DEP_OPTS"

ci/dash/build_src.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ source ./ci/dash/matrix.sh
1414
unset CC; unset CXX
1515
unset DISPLAY
1616

17-
if [ "$PULL_REQUEST" != "false" ]; then test/lint/commit-script-check.sh $COMMIT_RANGE; fi
17+
if [ "$PULL_REQUEST" != "false" ]; then test/lint/commit-script-check.sh "$COMMIT_RANGE"; fi
1818

1919
if [ "$CHECK_DOC" = 1 ]; then
2020
# TODO: Verify subtrees
@@ -28,7 +28,7 @@ if [ "$CHECK_DOC" = 1 ]; then
2828
test/lint/all-lint.py
2929
fi
3030

31-
ccache --zero-stats --max-size=$CCACHE_SIZE
31+
ccache --zero-stats --max-size="$CCACHE_SIZE"
3232

3333
if [ -n "$CONFIG_SHELL" ]; then
3434
export CONFIG_SHELL="$CONFIG_SHELL"
@@ -46,23 +46,23 @@ mkdir build-ci
4646
cd build-ci
4747

4848
bash -c "../configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( cat config.log && false)
49-
make distdir VERSION=$BUILD_TARGET
49+
make distdir VERSION="$BUILD_TARGET"
5050

51-
cd dashcore-$BUILD_TARGET
51+
cd "dashcore-$BUILD_TARGET"
5252
bash -c "./configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( cat config.log && false)
5353

5454
if [ "${RUN_TIDY}" = "true" ]; then
5555
MAYBE_BEAR="bear --config src/.bear-tidy-config"
5656
MAYBE_TOKEN="--"
5757
fi
5858

59-
bash -c "${MAYBE_BEAR} ${MAYBE_TOKEN} make ${MAKEJOBS} ${GOAL}" || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
59+
bash -c "${MAYBE_BEAR} ${MAYBE_TOKEN} make ${MAKEJOBS} ${GOAL}" || ( echo "Build failure. Verbose build follows." && make "$GOAL" V=1 ; false )
6060

6161
ccache --version | head -n 1 && ccache --show-stats
6262

6363
if [ -n "$USE_VALGRIND" ]; then
6464
echo "valgrind in USE!"
65-
${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh
65+
"${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh"
6666
fi
6767

6868
if [ "${RUN_TIDY}" = "true" ]; then

ci/dash/test_integrationtests.sh

+12-10
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ export LD_LIBRARY_PATH=$DEPENDS_DIR/$HOST/lib
2222

2323
if [ -n "$PREVIOUS_RELEASES_TO_DOWNLOAD" ]; then
2424
echo "Downloading previous releases: $PREVIOUS_RELEASES_TO_DOWNLOAD"
25+
# shellcheck disable=SC2086
2526
./test/get_previous_releases.py -b -t "$PREVIOUS_RELEASES_DIR" ${PREVIOUS_RELEASES_TO_DOWNLOAD}
2627
fi
2728

28-
cd build-ci/dashcore-$BUILD_TARGET
29+
cd "build-ci/dashcore-$BUILD_TARGET"
2930

3031
if [ "$SOCKETEVENTS" = "" ]; then
3132
# Let's switch socketevents mode to some random mode
@@ -42,29 +43,30 @@ echo "Using socketevents mode: $SOCKETEVENTS"
4243
EXTRA_ARGS="--dashd-arg=-socketevents=$SOCKETEVENTS"
4344

4445
set +e
45-
LD_LIBRARY_PATH=$DEPENDS_DIR/$HOST/lib ./test/functional/test_runner.py --ci --attempts=3 --ansi --combinedlogslen=4000 --timeout-factor=${TEST_RUNNER_TIMEOUT_FACTOR} ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir=$(pwd)/testdatadirs $PASS_ARGS $EXTRA_ARGS
46+
# shellcheck disable=SC2086
47+
LD_LIBRARY_PATH="$DEPENDS_DIR/$HOST/lib" ./test/functional/test_runner.py --ci --attempts=3 --ansi --combinedlogslen=4000 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir="$(pwd)/testdatadirs" $PASS_ARGS $EXTRA_ARGS
4648
RESULT=$?
4749
set -e
4850

4951
echo "Collecting logs..."
50-
BASEDIR=$(ls testdatadirs)
52+
BASEDIR="$(ls testdatadirs)"
5153
if [ "$BASEDIR" != "" ]; then
5254
mkdir testlogs
53-
TESTDATADIRS=$(ls testdatadirs/$BASEDIR)
55+
TESTDATADIRS=$(ls "testdatadirs/$BASEDIR")
5456
for d in $TESTDATADIRS; do
5557
[[ "$d" ]] || break # found nothing
5658
[[ "$d" != "cache" ]] || continue # skip cache dir
57-
mkdir testlogs/$d
58-
PYTHONIOENCODING=UTF-8 ./test/functional/combine_logs.py -c ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.log
59+
mkdir "testlogs/$d"
60+
PYTHONIOENCODING=UTF-8 ./test/functional/combine_logs.py -c "./testdatadirs/$BASEDIR/$d" > "./testlogs/$d/combined.log"
5961
# Disabled creation of combined.html: 40% smaller CI job artifacts
6062
# PYTHONIOENCODING=UTF-8 ./test/functional/combine_logs.py --html ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.html
61-
cd testdatadirs/$BASEDIR/$d
63+
cd "testdatadirs/$BASEDIR/$d"
6264
LOGFILES="$(find . -name 'debug.log' -or -name "test_framework.log")"
6365
cd ../../..
6466
for f in $LOGFILES; do
65-
d2="testlogs/$d/$(dirname $f)"
66-
mkdir -p $d2
67-
cp testdatadirs/$BASEDIR/$d/$f $d2/
67+
d2="testlogs/$d/$(dirname "$f")"
68+
mkdir -p "$d2"
69+
cp "testdatadirs/$BASEDIR/$d/$f" "$d2/"
6870
done
6971
done
7072
fi

ci/dash/test_unittests.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ if [ "$RUN_UNIT_TESTS" != "true" ] && [ "$RUN_UNIT_TESTS_SEQUENTIAL" != "true" ]
1616
exit 0
1717
fi
1818

19-
export BOOST_TEST_RANDOM=${BOOST_TEST_RANDOM:-1}
20-
export LD_LIBRARY_PATH=$DEPENDS_DIR/$HOST/lib
19+
export BOOST_TEST_RANDOM="${BOOST_TEST_RANDOM:-1}"
20+
export LD_LIBRARY_PATH="$DEPENDS_DIR/$HOST/lib"
2121

2222
export WINEDEBUG=fixme-all
2323
export BOOST_TEST_LOG_LEVEL=test_suite
2424

25-
cd build-ci/dashcore-$BUILD_TARGET
25+
cd "build-ci/dashcore-$BUILD_TARGET"
2626

2727
export WINEPREFIX="/tmp/wine"
2828
mkdir -p "$WINEPREFIX"
@@ -34,6 +34,6 @@ else
3434
if [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
3535
./src/test/test_dash --catch_system_errors=no -l test_suite
3636
else
37-
make $MAKEJOBS check VERBOSE=1
37+
make "$MAKEJOBS" check VERBOSE=1
3838
fi
3939
fi

ci/test/04_install.sh

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
3535
echo "Creating $DOCKER_NAME_TAG container to run in"
3636
${CI_RETRY_EXE} docker pull "$DOCKER_NAME_TAG"
3737

38+
# shellcheck disable=SC2086
3839
DOCKER_ID=$(docker run $DOCKER_ADMIN -idt \
3940
--mount type=bind,src=$BASE_ROOT_DIR,dst=/ro_base,readonly \
4041
--mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR \

contrib/auto_gdb/dash_dbg.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
# use testnet settings, if you need mainnet, use ~/.dashcore/dashd.pid file instead
66
export LC_ALL=C
77

8-
dash_pid=$(<~/.dashcore/testnet3/dashd.pid)
9-
sudo gdb -batch -ex "source debug.gdb" dashd ${dash_pid}
8+
dash_pid="$(<~/.dashcore/testnet3/dashd.pid)"
9+
sudo gdb -batch -ex "source debug.gdb" dashd "${dash_pid}"

contrib/containers/deploy/docker-entrypoint.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ set -e
1010
if [[ "$1" == "dashd" ]]; then
1111
# Because dashd only accept torcontrol= host as an ip only, we resolve it here and add to config
1212
if [[ "$TOR_CONTROL_HOST" ]] && [[ "$TOR_CONTROL_PORT" ]] && [[ "$TOR_PROXY_PORT" ]]; then
13-
TOR_IP=$(getent hosts $TOR_CONTROL_HOST | cut -d ' ' -f 1)
13+
TOR_IP=$(getent hosts "$TOR_CONTROL_HOST" | cut -d ' ' -f 1)
1414
echo "proxy=$TOR_IP:$TOR_PROXY_PORT" >> "$HOME/.dashcore/dash.conf"
15-
echo "Added "proxy=$TOR_IP:$TOR_PROXY_PORT" to $HOME/.dashcore/dash.conf"
15+
echo "Added \"proxy=$TOR_IP:$TOR_PROXY_PORT\" to $HOME/.dashcore/dash.conf"
1616
echo "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" >> "$HOME/.dashcore/dash.conf"
17-
echo "Added "torcontrol=$TOR_IP:$TOR_CONTROL_PORT" to $HOME/.dashcore/dash.conf"
17+
echo "Added \"torcontrol=$TOR_IP:$TOR_CONTROL_PORT\" to $HOME/.dashcore/dash.conf"
1818
echo -e "\n"
1919
else
2020
echo "Tor control credentials not provided"

test/lint/lint-cppcheck-dash.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ IGNORED_WARNINGS=(
6262
)
6363

6464
# We should attempt to update this with all dash specific code
65+
# shellcheck disable=SC2046
6566
FILES=$(git ls-files -- $(cat test/util/data/non-backported.txt))
6667

6768

@@ -86,12 +87,12 @@ if [[ -n "$CACHE_DIR" ]]; then
8687
else
8788
CPPCHECK_DIR=$SCRIPT_DIR/.cppcheck/
8889
fi
89-
if [ ! -d $CPPCHECK_DIR ]
90+
if [ ! -d "$CPPCHECK_DIR" ]
9091
then
91-
mkdir -p $CPPCHECK_DIR
92+
mkdir -p "$CPPCHECK_DIR"
9293
fi
9394
WARNINGS=$(echo "${FILES}" | \
94-
xargs cppcheck --enable=all --inline-suppr --suppress=missingIncludeSystem --cppcheck-build-dir=$CPPCHECK_DIR -j "$(getconf _NPROCESSORS_ONLN)" --language=c++ --std=c++20 --template=gcc -D__cplusplus -DENABLE_WALLET -DCLIENT_VERSION_BUILD -DCLIENT_VERSION_IS_RELEASE -DCLIENT_VERSION_MAJOR -DCLIENT_VERSION_MINOR -DCOPYRIGHT_YEAR -DDEBUG -DUSE_EPOLL -DCHAR_BIT=8 -I src/ -q 2>&1 | sort -u | \
95+
xargs cppcheck --enable=all --inline-suppr --suppress=missingIncludeSystem --cppcheck-build-dir="$CPPCHECK_DIR" -j "$(getconf _NPROCESSORS_ONLN)" --language=c++ --std=c++20 --template=gcc -D__cplusplus -DENABLE_WALLET -DCLIENT_VERSION_BUILD -DCLIENT_VERSION_IS_RELEASE -DCLIENT_VERSION_MAJOR -DCLIENT_VERSION_MINOR -DCOPYRIGHT_YEAR -DDEBUG -DUSE_EPOLL -DCHAR_BIT=8 -I src/ -q 2>&1 | sort -u | \
9596
grep -E "${ENABLED_CHECKS_REGEXP}" | \
9697
grep -vE "${IGNORED_WARNINGS_REGEXP}" | \
9798
grep -E "${FILES_REGEXP}")

test/lint/lint-shell.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
# Disabled warnings:
1616
DISABLED = [
17-
'SC2046', # Quote this to prevent word splitting.
18-
'SC2086', # Double quote to prevent globbing and word splitting.
1917
'SC2162', # read without -r will mangle backslashes.
2018
]
2119

0 commit comments

Comments
 (0)