Skip to content

Commit d393624

Browse files
author
Leonardo
authored
Merge pull request #10585 from ethereum/fix-quoting-and-whitespace-in-shell-scripts
Fix quoting in shell scripts
2 parents 358324e + c19464f commit d393624

30 files changed

+137
-155
lines changed

.circleci/soltest.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set -e
3636

3737
OPTIMIZE=${OPTIMIZE:-"0"}
3838
EVM=${EVM:-"invalid"}
39-
REPODIR="$(realpath $(dirname $0)/..)"
39+
REPODIR="$(realpath "$(dirname "$0")/..")"
4040

4141
source "${REPODIR}/scripts/common.sh"
4242
# Test result output directory (CircleCI is reading test results from here)
@@ -60,4 +60,4 @@ test "${ABI_ENCODER_V1}" = "1" && SOLTEST_ARGS="${SOLTEST_ARGS} --abiencoderv1"
6060

6161
echo "Running ${REPODIR}/build/test/soltest ${BOOST_TEST_ARGS} -- ${SOLTEST_ARGS}"
6262

63-
${REPODIR}/build/test/soltest ${BOOST_TEST_ARGS} -- ${SOLTEST_ARGS}
63+
"${REPODIR}/build/test/soltest" ${BOOST_TEST_ARGS} -- ${SOLTEST_ARGS}

.circleci/soltest_all.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# ------------------------------------------------------------------------------
2727
set -e
2828

29-
REPODIR="$(realpath $(dirname $0)/..)"
29+
REPODIR="$(realpath "$(dirname "$0")"/..)"
3030

3131
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul)
3232
OPTIMIZE_VALUES=(0 1)
@@ -65,9 +65,9 @@ STEP=$(($STEP + 1))
6565
[[ " $RUN_STEPS " =~ " $STEP " ]] && EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V1=1 BOOST_TEST_ARGS="-t !smtCheckerTests" "${REPODIR}/.circleci/soltest.sh"
6666
STEP=$(($STEP + 1))
6767

68-
for OPTIMIZE in ${OPTIMIZE_VALUES[@]}
68+
for OPTIMIZE in "${OPTIMIZE_VALUES[@]}"
6969
do
70-
for EVM in ${EVM_VALUES[@]}
70+
for EVM in "${EVM_VALUES[@]}"
7171
do
7272
# run tests against hera ewasm evmc vm, only if OPTIMIZE == 0 and evm version is byzantium
7373
EWASM_ARGS=""

scripts/ASTImportTest.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SPLITSOURCES=${REPO_ROOT}/scripts/splitSources.py
1616

1717
SYNTAXTESTS_DIR="${REPO_ROOT}/test/libsolidity/syntaxTests"
1818
ASTJSONTESTS_DIR="${REPO_ROOT}/test/libsolidity/ASTJSON"
19-
NSOURCES="$(find $SYNTAXTESTS_DIR -type f | wc -l)"
19+
NSOURCES="$(find "$SYNTAXTESTS_DIR" -type f | wc -l)"
2020

2121
# DEV_DIR="${REPO_ROOT}/../tmp/contracts/"
2222
# NSOURCES="$(find $DEV_DIR -type f | wc -l)" #TODO use find command
@@ -25,7 +25,7 @@ FAILED=0
2525
UNCOMPILABLE=0
2626
TESTED=0
2727

28-
if [ $(ls | wc -l) -ne 0 ]; then
28+
if [ "$(ls | wc -l)" -ne 0 ]; then
2929
echo "Test directory not empty. Skipping!"
3030
exit -1
3131
fi
@@ -37,10 +37,10 @@ fi
3737
# $1 name of the file to be exported and imported
3838
# $2 any files needed to do so that might be in parent directories
3939
function testImportExportEquivalence {
40-
if $SOLC $1 $2 > /dev/null 2>&1
40+
if $SOLC "$1" $2 > /dev/null 2>&1
4141
then
4242
# save exported json as expected result (silently)
43-
$SOLC --combined-json ast,compact-format --pretty-json $1 $2> expected.json 2> /dev/null
43+
$SOLC --combined-json ast,compact-format --pretty-json "$1" $2 > expected.json 2> /dev/null
4444
# import it, and export it again as obtained result (silently)
4545
$SOLC --import-ast --combined-json ast,compact-format --pretty-json expected.json > obtained.json 2> /dev/null
4646
if [ $? -ne 0 ]
@@ -81,15 +81,15 @@ echo "Looking at $NSOURCES .sol files..."
8181
WORKINGDIR=$PWD
8282

8383
# for solfile in $(find $DEV_DIR -name *.sol)
84-
for solfile in $(find $SYNTAXTESTS_DIR $ASTJSONTESTS_DIR -name *.sol)
84+
for solfile in $(find "$SYNTAXTESTS_DIR" "$ASTJSONTESTS_DIR" -name *.sol)
8585
do
8686
echo -n "."
8787
# create a temporary sub-directory
8888
FILETMP=$(mktemp -d)
89-
cd $FILETMP
89+
cd "$FILETMP"
9090

9191
set +e
92-
OUTPUT=$($SPLITSOURCES $solfile)
92+
OUTPUT=$("$SPLITSOURCES" "$solfile")
9393
SPLITSOURCES_RC=$?
9494
set -e
9595
if [ ${SPLITSOURCES_RC} == 0 ]
@@ -103,29 +103,29 @@ do
103103
done
104104
elif [ ${SPLITSOURCES_RC} == 1 ]
105105
then
106-
testImportExportEquivalence $solfile
106+
testImportExportEquivalence "$solfile"
107107
elif [ ${SPLITSOURCES_RC} == 2 ]
108108
then
109109
# The script will exit with return code 2, if an UnicodeDecodeError occurred.
110110
# This is the case if e.g. some tests are using invalid utf-8 sequences. We will ignore
111111
# these errors, but print the actual output of the script.
112112
echo -e "\n${OUTPUT}\n"
113-
testImportExportEquivalence $solfile
113+
testImportExportEquivalence "$solfile"
114114
else
115115
# All other return codes will be treated as critical errors. The script will exit.
116116
echo -e "\nGot unexpected return code ${SPLITSOURCES_RC} from ${SPLITSOURCES}. Aborting."
117117
echo -e "\n${OUTPUT}\n"
118118

119-
cd $WORKINGDIR
119+
cd "$WORKINGDIR"
120120
# Delete temporary files
121-
rm -rf $FILETMP
121+
rm -rf "$FILETMP"
122122

123123
exit 1
124124
fi
125125

126-
cd $WORKINGDIR
126+
cd "$WORKINGDIR"
127127
# Delete temporary files
128-
rm -rf $FILETMP
128+
rm -rf "$FILETMP"
129129
done
130130

131131
echo ""

scripts/build_emscripten.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ else
3535
fi
3636

3737
# solbuildpackpusher/solidity-buildpack-deps:emscripten-4
38-
docker run -v $(pwd):/root/project -w /root/project \
38+
docker run -v "$(pwd):/root/project" -w /root/project \
3939
solbuildpackpusher/solidity-buildpack-deps@sha256:434719d8104cab47712dd1f56f255994d04eb65b802c0d382790071c1a0c074b \
40-
./scripts/ci/build_emscripten.sh $BUILD_DIR
40+
./scripts/ci/build_emscripten.sh "$BUILD_DIR"

scripts/bytecodecompare/storebytecode.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ TMPDIR=$(mktemp -d)
4646
git clone --depth 1 https://github.com/ethereum/solc-js.git solc-js
4747
( cd solc-js; npm install )
4848
cp "$REPO_ROOT/emscripten_build/libsolc/soljson.js" solc-js/
49-
cp ""$REPO_ROOT"/scripts/bytecodecompare/prepare_report.js" .
49+
cp "$REPO_ROOT/scripts/bytecodecompare/prepare_report.js" .
5050
echo "Running the compiler..."
5151
./prepare_report.js *.sol > report.txt
5252
echo "Finished running the compiler."

scripts/chk_shellscripts/chk_shellscripts.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ find . -type f -name "*.sh" | sort >"${FOUND_FILES_TMP}"
1717

1818
SHELLCHECK=${SHELLCHECK:-"$(command -v -- shellcheck)"}
1919
if [ ! -f "${SHELLCHECK}" ]; then
20-
echo "error: shellcheck '${SHELLCHECK}' not found."
21-
exit 1
20+
echo "error: shellcheck '${SHELLCHECK}' not found."
21+
exit 1
2222
fi
2323

2424
FILES=$(join -v2 "${IGNORE_FILES_TMP}" "${FOUND_FILES_TMP}")
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,21 @@
1-
./test/docsCodeStyle.sh
21
./test/cmdlineTests.sh
3-
./scripts/isoltest.sh
4-
./scripts/get_version.sh
52
./scripts/soltest.sh
6-
./scripts/test_emscripten.sh
73
./scripts/wasm-rebuild/docker-scripts/rebuild_tags.sh
84
./scripts/wasm-rebuild/docker-scripts/rebuild_current.sh
95
./scripts/wasm-rebuild/docker-scripts/genbytecode.sh
10-
./scripts/wasm-rebuild/docker-scripts/patch.sh
11-
./scripts/wasm-rebuild/rebuild.sh
12-
./scripts/build_emscripten.sh
136
./scripts/ci/build_emscripten.sh
14-
./scripts/docker_build.sh
157
./scripts/docs_version_pragma_check.sh
168
./scripts/uniqueErrors.sh
179
./scripts/tests.sh
18-
./scripts/docker_deploy.sh
1910
./scripts/bytecodecompare/storebytecode.sh
2011
./scripts/deps-ppa/static_z3.sh
2112
./scripts/ASTImportTest.sh
2213
./scripts/install_static_z3.sh
23-
./scripts/install_obsolete_jsoncpp_1_7_4.sh
2414
./scripts/install_deps.sh
25-
./scripts/build.sh
26-
./scripts/run_proofs.sh
2715
./scripts/common_cmdline.sh
2816
./scripts/docker_deploy_manual.sh
2917
./scripts/endToEndExtraction/create_traces.sh
30-
./scripts/release.sh
31-
./scripts/download_ossfuzz_corpus.sh
3218
./scripts/release_ppa.sh
33-
./scripts/install_cmake.sh
34-
./scripts/release_emscripten.sh
3519
./scripts/create_source_tarball.sh
36-
./scripts/docs.sh
3720
./.circleci/soltest.sh
38-
./.circleci/osx_install_dependencies.sh
3921
./.circleci/soltest_all.sh

scripts/ci/build_emscripten.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ then
5959
echo -n "$CIRCLE_SHA1" >commit_hash.txt
6060
fi
6161

62-
mkdir -p $BUILD_DIR
63-
cd $BUILD_DIR
62+
mkdir -p "$BUILD_DIR"
63+
cd "$BUILD_DIR"
6464
emcmake cmake \
65-
-DCMAKE_BUILD_TYPE=Release \
66-
-DBoost_USE_STATIC_LIBS=1 \
67-
-DBoost_USE_STATIC_RUNTIME=1 \
68-
-DTESTS=0 \
65+
-DCMAKE_BUILD_TYPE=Release \
66+
-DBoost_USE_STATIC_LIBS=1 \
67+
-DBoost_USE_STATIC_RUNTIME=1 \
68+
-DTESTS=0 \
6969
..
7070
make soljson
7171
# Patch soljson.js for backwards compatibility.
@@ -75,8 +75,8 @@ sed -i -e 's/addFunction(func,sig){/addFunction(func,sig){sig=sig||"viiiii";/' l
7575

7676
cd ..
7777
mkdir -p upload
78-
cp $BUILD_DIR/libsolc/soljson.js upload/
79-
cp $BUILD_DIR/libsolc/soljson.js ./
78+
cp "$BUILD_DIR/libsolc/soljson.js" upload/
79+
cp "$BUILD_DIR/libsolc/soljson.js" ./
8080

8181
OUTPUT_SIZE=`ls -la soljson.js`
8282

scripts/common_cmdline.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ function compileFull()
3939
fi
4040
local args=$FULLARGS
4141
if [[ $1 = '-v' ]]; then
42-
if (echo $2 | grep -Po '(?<=0.4.)\d+' >/dev/null); then
43-
patch=$(echo $2 | grep -Po '(?<=0.4.)\d+')
42+
if (echo "$2" | grep -Po '(?<=0.4.)\d+' >/dev/null); then
43+
patch=$(echo "$2" | grep -Po '(?<=0.4.)\d+')
4444
if (( patch < 22 )); then
4545
args=$OLDARGS
4646
fi

scripts/deps-ppa/static_z3.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ DISTRIBUTIONS="focal groovy"
3232
for distribution in $DISTRIBUTIONS
3333
do
3434
cd /tmp/
35-
rm -rf $distribution
36-
mkdir $distribution
37-
cd $distribution
35+
rm -rf "$distribution"
36+
mkdir "$distribution"
37+
cd "$distribution"
3838

3939
pparepo=cpp-build-deps
4040
ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files
@@ -190,7 +190,7 @@ echo "3.0 (quilt)" > debian/source/format
190190
chmod +x debian/rules
191191

192192
versionsuffix=1ubuntu0~${distribution}
193-
EMAIL="$email" dch -v 1:${debversion}-${versionsuffix} "build of ${version}"
193+
EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}"
194194

195195
# build source package
196196
# If packages is rejected because original source is already present, add
@@ -199,13 +199,13 @@ EMAIL="$email" dch -v 1:${debversion}-${versionsuffix} "build of ${version}"
199199
debuild -S -d -sa -us -uc
200200

201201
# prepare .changes file for Launchpad
202-
sed -i -e s/UNRELEASED/${distribution}/ -e s/urgency=medium/urgency=low/ ../*.changes
202+
sed -i -e "s/UNRELEASED/${distribution}/" -e s/urgency=medium/urgency=low/ ../*.changes
203203

204204
# check if ubuntu already has the source tarball
205205
(
206206
cd ..
207-
orig=${packagename}_${debversion}.orig.tar.gz
208-
orig_size=$(ls -l $orig | cut -d ' ' -f 5)
207+
orig="${packagename}_${debversion}.orig.tar.gz"
208+
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
209209
orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
210210
orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
211211
orig_md5=$(md5sum $orig | cut -d ' ' -f 1)
@@ -218,15 +218,15 @@ then
218218
new_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
219219
new_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
220220
new_md5=$(md5sum $orig | cut -d ' ' -f 1)
221-
sed -i -e s,$orig_sha1,$new_sha1,g -e s,$orig_sha256,$new_sha256,g -e s,$orig_size,$new_size,g -e s,$orig_md5,$new_md5,g *.dsc
222-
sed -i -e s,$orig_sha1,$new_sha1,g -e s,$orig_sha256,$new_sha256,g -e s,$orig_size,$new_size,g -e s,$orig_md5,$new_md5,g *.changes
221+
sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" *.dsc
222+
sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" *.changes
223223
fi
224224
)
225225

226226
# sign the package
227-
debsign --re-sign -k ${keyid} ../${packagename}_${debversion}-${versionsuffix}_source.changes
227+
debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes"
228228

229229
# upload
230-
dput ${pparepo} ../${packagename}_${debversion}-${versionsuffix}_source.changes
230+
dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes"
231231

232232
done

0 commit comments

Comments
 (0)