Skip to content

Commit bfc64e3

Browse files
authored
Merge pull request #701 from tgross35/shellcheck-fixes
Fix some warnings from shellcheck
2 parents ea86bf9 + b1e6c1d commit bfc64e3

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

ci/run-docker.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ run() {
1414
# will be owned by root
1515
mkdir -p target
1616

17-
if [ $(uname -s) = "Linux" ] && [ -z "${DOCKER_BASE_IMAGE:-}" ]; then
17+
if [ "$(uname -s)" = "Linux" ] && [ -z "${DOCKER_BASE_IMAGE:-}" ]; then
1818
# Share the host rustc and target. Do this only on Linux and if the image
1919
# isn't overridden
2020
run_args=(
@@ -43,19 +43,21 @@ run() {
4343

4444
if [ "${GITHUB_ACTIONS:-}" = "true" ]; then
4545
# Enable Docker image caching on GHA
46-
46+
4747
build_cmd=("buildx" "build")
4848
build_args=(
4949
"--cache-from" "type=local,src=/tmp/.buildx-cache"
5050
"--cache-to" "type=local,dest=/tmp/.buildx-cache-new"
51-
"${build_args[@]:-}"
51+
# This is the beautiful bash syntax for expanding an array but neither
52+
# raising an error nor returning an empty string if the array is empty.
53+
"${build_args[@]:+"${build_args[@]}"}"
5254
"--load"
5355
)
5456
fi
5557

56-
docker ${build_cmd[@]:-build} \
58+
docker "${build_cmd[@]:-build}" \
5759
-t "builtins-$target" \
58-
${build_args[@]:-} \
60+
"${build_args[@]:-}" \
5961
"ci/docker/$target"
6062
docker run \
6163
--rm \
@@ -64,7 +66,7 @@ run() {
6466
-e "CARGO_TARGET_DIR=/builtins-target" \
6567
-v "$(pwd):/checkout:ro" \
6668
-w /checkout \
67-
${run_args[@]:-} \
69+
"${run_args[@]:-}" \
6870
--init \
6971
"builtins-$target" \
7072
sh -c "$run_cmd"

ci/run.sh

+21-10
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,24 @@ fi
3838

3939
if [ "${TEST_VERBATIM:-}" = "1" ]; then
4040
verb_path=$(cmd.exe //C echo \\\\?\\%cd%\\testcrate\\target2)
41-
cargo build --manifest-path testcrate/Cargo.toml --target $target --target-dir $verb_path --features c
41+
cargo build --manifest-path testcrate/Cargo.toml \
42+
--target "$target" --target-dir "$verb_path" --features c
4243
fi
4344

44-
if [ -d /builtins-target ]; then
45-
rlib_paths=/builtins-target/"${target}"/debug/deps/libcompiler_builtins-*.rlib
46-
else
47-
rlib_paths=target/"${target}"/debug/deps/libcompiler_builtins-*.rlib
48-
fi
45+
declare -a rlib_paths
46+
47+
# Set the `rlib_paths` global array to a list of all compiler-builtins rlibs
48+
update_rlib_paths() {
49+
if [ -d /builtins-target ]; then
50+
rlib_paths=( /builtins-target/"${target}"/debug/deps/libcompiler_builtins-*.rlib )
51+
else
52+
rlib_paths=( target/"${target}"/debug/deps/libcompiler_builtins-*.rlib )
53+
fi
54+
}
4955

5056
# Remove any existing artifacts from previous tests that don't set #![compiler_builtins]
51-
rm -f $rlib_paths
57+
update_rlib_paths
58+
rm -f "${rlib_paths[@]}"
5259

5360
cargo build --target "$target"
5461
cargo build --target "$target" --release
@@ -76,6 +83,7 @@ NM=$(find "$(rustc --print sysroot)" \( -name llvm-nm -o -name llvm-nm.exe \) )
7683
if [ "$NM" = "" ]; then
7784
NM="${PREFIX}nm"
7885
fi
86+
7987
# i686-pc-windows-gnu tools have a dependency on some DLLs, so run it with
8088
# rustup run to ensure that those are in PATH.
8189
TOOLCHAIN="$(rustup show active-toolchain | sed 's/ (default)//')"
@@ -84,11 +92,13 @@ if [[ "$TOOLCHAIN" == *i686-pc-windows-gnu ]]; then
8492
fi
8593

8694
# Look out for duplicated symbols when we include the compiler-rt (C) implementation
87-
for rlib in $rlib_paths; do
95+
update_rlib_paths
96+
for rlib in "${rlib_paths[@]}"; do
8897
set +x
8998
echo "================================================================"
9099
echo "checking $rlib for duplicate symbols"
91100
echo "================================================================"
101+
set -x
92102

93103
duplicates_found=0
94104

@@ -108,7 +118,7 @@ for rlib in $rlib_paths; do
108118
fi
109119
done
110120

111-
rm -f $rlib_paths
121+
rm -f "${rlib_paths[@]}"
112122

113123
build_intrinsics() {
114124
cargo build --target "$target" -v --example intrinsics "$@"
@@ -128,7 +138,8 @@ CARGO_PROFILE_RELEASE_LTO=true \
128138
cargo build --target "$target" --example intrinsics --release
129139

130140
# Ensure no references to any symbols from core
131-
for rlib in $(echo $rlib_paths); do
141+
update_rlib_paths
142+
for rlib in "${rlib_paths[@]}"; do
132143
set +x
133144
echo "================================================================"
134145
echo "checking $rlib for references to core"

0 commit comments

Comments
 (0)