Skip to content

Commit 829dcfb

Browse files
committed
partial bitcoin#23462: Enable SC2046 and SC2086 shellcheck rules
1 parent df6be0e commit 829dcfb

19 files changed

+59
-49
lines changed

ci/lint/04_install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export LC_ALL=C
88

99
${CI_RETRY_EXE} apt-get update
1010
${CI_RETRY_EXE} apt-get install -y clang-format-9 python3-pip curl git gawk jq
11-
update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-9 ) 100
12-
update-alternatives --install /usr/bin/clang-format-diff clang-format-diff $(which clang-format-diff-9) 100
11+
update-alternatives --install /usr/bin/clang-format clang-format "$(which clang-format-9 )" 100
12+
update-alternatives --install /usr/bin/clang-format-diff clang-format-diff "$(which clang-format-diff-9)" 100
1313

1414
${CI_RETRY_EXE} pip3 install codespell==2.0.0
1515
${CI_RETRY_EXE} pip3 install flake8==3.8.3

ci/lint/06_script.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ test/lint/lint-all.sh
2525

2626
if [ "$CIRRUS_REPO_FULL_NAME" = "dashpay/dash" ] && [ -n "$CIRRUS_CRON" ]; then
2727
git log --merges --before="2 days ago" -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit
28-
${CI_RETRY_EXE} gpg --keyserver hkps://keys.openpgp.org --recv-keys $(<contrib/verify-commits/trusted-keys) &&
28+
mapfile -t KEYS < contrib/verify-commits/trusted-keys
29+
${CI_RETRY_EXE} gpg --keyserver hkps://keys.openpgp.org --recv-keys "${KEYS[@]}" &&
2930
./contrib/verify-commits/verify-commits.py --clean-merge=2;
3031
fi
3132

ci/test/04_install.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fi
1212

1313
if [ "$CI_OS_NAME" == "macos" ]; then
1414
sudo -H pip3 install --upgrade pip
15+
# shellcheck disable=SC2086
1516
IN_GETOPT_BIN="/usr/local/opt/gnu-getopt/bin/getopt" ${CI_RETRY_EXE} pip3 install --user $PIP_PACKAGES
1617
fi
1718

@@ -49,7 +50,7 @@ else
4950
fi
5051

5152
DOCKER_EXEC () {
52-
$DOCKER_CI_CMD_PREFIX bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*"
53+
$DOCKER_CI_CMD_PREFIX bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd \"$P_CI_DIR\" && $*"
5354
}
5455
export -f DOCKER_EXEC
5556

@@ -59,11 +60,12 @@ fi
5960

6061
if [[ $DOCKER_NAME_TAG == centos* ]]; then
6162
${CI_RETRY_EXE} DOCKER_EXEC yum -y install epel-release
62-
${CI_RETRY_EXE} DOCKER_EXEC yum -y install $DOCKER_PACKAGES $PACKAGES
63+
${CI_RETRY_EXE} DOCKER_EXEC yum -y install "$DOCKER_PACKAGES" "$PACKAGES"
6364
elif [ "$CI_USE_APT_INSTALL" != "no" ]; then
6465
${CI_RETRY_EXE} DOCKER_EXEC apt-get update
65-
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
66+
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y "$PACKAGES" "$DOCKER_PACKAGES"
6667
if [ -n "$PIP_PACKAGES" ]; then
68+
# shellcheck disable=SC2086
6769
${CI_RETRY_EXE} pip3 install --user $PIP_PACKAGES
6870
fi
6971
fi
@@ -74,14 +76,14 @@ if [ "$CI_OS_NAME" == "macos" ]; then
7476
else
7577
DOCKER_EXEC free -m -h
7678
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
77-
DOCKER_EXEC echo $(lscpu | grep Endian)
79+
DOCKER_EXEC echo "$(lscpu | grep Endian)"
7880
fi
7981
DOCKER_EXEC echo "Free disk space:"
8082
DOCKER_EXEC df -h
8183

8284
if [ "$RUN_FUZZ_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS_SEQUENTIAL" = "true" ]; then
83-
if [ ! -d ${DIR_QA_ASSETS} ]; then
84-
DOCKER_EXEC git clone --depth=1 https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
85+
if [ ! -d "${DIR_QA_ASSETS}" ]; then
86+
DOCKER_EXEC git clone --depth=1 https://github.com/bitcoin-core/qa-assets "${DIR_QA_ASSETS}"
8587
fi
8688

8789
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/
@@ -91,17 +93,17 @@ DOCKER_EXEC mkdir -p "${BASE_SCRATCH_DIR}/sanitizer-output/"
9193

9294
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
9395
echo "Create $BASE_ROOT_DIR"
94-
DOCKER_EXEC rsync -a /ro_base/ $BASE_ROOT_DIR
96+
DOCKER_EXEC rsync -a /ro_base/ "$BASE_ROOT_DIR"
9597
fi
9698

9799
if [ "$USE_BUSY_BOX" = "true" ]; then
98100
echo "Setup to use BusyBox utils"
99-
DOCKER_EXEC mkdir -p $BASE_SCRATCH_DIR/bins/
101+
DOCKER_EXEC mkdir -p "${BASE_SCRATCH_DIR}/bins/"
100102
# tar excluded for now because it requires passing in the exact archive type in ./depends (fixed in later BusyBox version)
101103
# find excluded for now because it does not recognize the -delete option in ./depends (fixed in later BusyBox version)
102104
# ar excluded for now because it does not recognize the -q option in ./depends (unknown if fixed)
103105
# shellcheck disable=SC1010
104-
DOCKER_EXEC for util in \$\(busybox --list \| grep -v "^ar$" \| grep -v "^tar$" \| grep -v "^find$"\)\; do ln -s \$\(command -v busybox\) $BASE_SCRATCH_DIR/bins/\$util\; done
106+
DOCKER_EXEC for util in \$\(busybox --list \| grep -v "^ar$" \| grep -v "^tar$" \| grep -v "^find$"\)\; do ln -s \$\(command -v busybox\) "${BASE_SCRATCH_DIR}/bins/\$util"\; done
105107
# Print BusyBox version
106108
DOCKER_EXEC patch --help
107109
fi

ci/test/05_before_script.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export LC_ALL=C.UTF-8
88

99
# Make sure default datadir does not exist and is never read by creating a dummy file
1010
if [ "$CI_OS_NAME" == "macos" ]; then
11-
echo > $HOME/Library/Application\ Support/DashCore
11+
echo > "${HOME}/Library/Application Support/DashCore"
1212
else
1313
DOCKER_EXEC echo \> \$HOME/.dashcore
1414
fi
1515

16-
DOCKER_EXEC mkdir -p ${DEPENDS_DIR}/SDKs ${DEPENDS_DIR}/sdk-sources
16+
DOCKER_EXEC mkdir -p "${DEPENDS_DIR}/SDKs" "${DEPENDS_DIR}/sdk-sources"
1717

1818
if [ -n "$XCODE_VERSION" ] && [ ! -f "$OSX_SDK_PATH" ]; then
1919
DOCKER_EXEC curl --location --fail "${SDK_URL}/${OSX_SDK_BASENAME}" -o "$OSX_SDK_PATH"
@@ -22,7 +22,7 @@ if [ -n "$XCODE_VERSION" ] && [ -f "$OSX_SDK_PATH" ]; then
2222
DOCKER_EXEC tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH"
2323
fi
2424
if [[ $HOST = *-mingw32 ]]; then
25-
DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\)
25+
DOCKER_EXEC update-alternatives --set "${HOST}-g++" \$\(which "${HOST}-g++-posix"\)
2626
fi
2727
if [ -z "$NO_DEPENDS" ]; then
2828
if [[ $DOCKER_NAME_TAG == centos* ]]; then
@@ -33,7 +33,7 @@ if [ -z "$NO_DEPENDS" ]; then
3333
else
3434
SHELL_OPTS="CONFIG_SHELL="
3535
fi
36-
DOCKER_EXEC $SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS LOG=1
36+
DOCKER_EXEC "$SHELL_OPTS" make "$MAKEJOBS" -C depends HOST="$HOST" "$DEP_OPTS" LOG=1
3737
fi
3838
if [ -n "$PREVIOUS_RELEASES_TO_DOWNLOAD" ]; then
3939
DOCKER_EXEC test/get_previous_releases.py -b -t "$PREVIOUS_RELEASES_DIR" "${PREVIOUS_RELEASES_TO_DOWNLOAD}"

ci/test/wrap-valgrind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
for b_name in "${BASE_OUTDIR}/bin"/*; do
1010
# shellcheck disable=SC2044
11-
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename $b_name)); do
11+
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
1212
echo "Wrap $b ..."
1313
mv "$b" "${b}_orig"
1414
echo '#!/usr/bin/env bash' > "$b"

ci/test/wrap-wine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/minisketch/test{,-verify},src/univalue/{no_nul,test_json,unitester,object}}.exe; do
1010
# shellcheck disable=SC2044
11-
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename $b_name)"); do
11+
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
1212
if (file "$b" | grep "Windows"); then
1313
echo "Wrap $b ..."
1414
mv "$b" "${b}_orig"

contrib/devtools/gen-manpages.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ BITCOINTX=${BITCOINTX:-$BINDIR/dash-tx}
1616
WALLET_TOOL=${WALLET_TOOL:-$BINDIR/dash-wallet}
1717
BITCOINQT=${BITCOINQT:-$BINDIR/qt/dash-qt}
1818

19-
[ ! -x $BITCOIND ] && echo "$BITCOIND not found or not executable." && exit 1
19+
[ ! -x "$BITCOIND" ] && echo "$BITCOIND not found or not executable." && exit 1
2020

2121
# Don't allow man pages to be generated for binaries built from a dirty tree
2222
DIRTY=""
@@ -29,7 +29,7 @@ done
2929
if [ -n "$DIRTY" ]
3030
then
3131
echo -e "WARNING: the following binaries were built from a dirty tree:\n"
32-
echo -e $DIRTY
32+
echo -e "$DIRTY"
3333
echo "man pages generated from dirty binaries should NOT be committed."
3434
echo "To properly generate man pages, please commit your changes to the above binaries, rebuild them, then run this script again."
3535
fi
@@ -45,8 +45,8 @@ $BITCOIND --version | sed -n '1!p' >> footer.h2m
4545

4646
for cmd in $BITCOIND $BITCOINCLI $BITCOINTX $WALLET_TOOL $BITCOINQT; do
4747
cmdname="${cmd##*/}"
48-
help2man -N --version-string=${BTCVER[0]} --include=footer.h2m -o ${MANDIR}/${cmdname}.1 ${cmd}
49-
sed -i "s/\\\-${BTCVER[1]}//g" ${MANDIR}/${cmdname}.1
48+
help2man -N --version-string="${BTCVER[0]}" --include=footer.h2m -o "${MANDIR}/${cmdname}.1" "${cmd}"
49+
sed -i "s/\\\-${BTCVER[1]}//g" "${MANDIR}/${cmdname}.1"
5050
done
5151

5252
rm -f footer.h2m

contrib/install_db4.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ expand_path() {
2020
cd "${1}" && pwd -P
2121
}
2222

23-
BDB_PREFIX="$(expand_path ${1})/db4"; shift;
23+
BDB_PREFIX="$(expand_path "${1}")/db4"; shift;
2424
BDB_VERSION='db-4.8.30.NC'
2525
BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
2626
BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"

contrib/verify-commits/pre-push-hook.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ if ! [[ "$2" =~ ^(git@)?(www.)?github.com(:|/)dashpay/dash(.git)?$ ]]; then
99
fi
1010

1111
while read LINE; do
12-
set -- A $LINE
12+
set -- A "$LINE"
1313
if [ "$4" != "refs/heads/master" ]; then
1414
continue
1515
fi
16-
if ! ./contrib/verify-commits/verify-commits.py $3 > /dev/null 2>&1; then
16+
if ! ./contrib/verify-commits/verify-commits.py "$3" > /dev/null 2>&1; then
1717
echo "ERROR: A commit is not signed, can't push"
1818
./contrib/verify-commits/verify-commits.py
1919
exit 1

contrib/windeploy/detached-sig-create.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TIMESERVER=http://timestamp.comodoca.com
2323
CERTFILE="win-codesign.cert"
2424

2525
mkdir -p "${OUTSUBDIR}"
26+
# shellcheck disable=SC2046
2627
basename -a $(ls -1 "${SRCDIR}"/*-unsigned.exe) | while read UNSIGNED; do
2728
echo Signing "${UNSIGNED}"
2829
"${OSSLSIGNCODE}" sign -certs "${CERTFILE}" -t "${TIMESERVER}" -h sha256 -in "${SRCDIR}/${UNSIGNED}" -out "${WORKDIR}/${UNSIGNED}" "$@"

0 commit comments

Comments
 (0)