Skip to content

Commit 19931e2

Browse files
authored
Merge pull request rust-lang#1109 from jakobhellermann/shellcheck
fix (many) shellcheck warnings
2 parents 1aaa024 + 33a9044 commit 19931e2

File tree

9 files changed

+50
-50
lines changed

9 files changed

+50
-50
lines changed

build.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ else
3434
cargo build
3535
fi
3636

37-
rm -rf $target_dir
38-
mkdir $target_dir
39-
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* $target_dir/
40-
cp -a rust-toolchain scripts/config.sh scripts/cargo.sh $target_dir
37+
rm -rf "$target_dir"
38+
mkdir "$target_dir"
39+
cp -a target/$CHANNEL/cg_clif{,_build_sysroot} target/$CHANNEL/*rustc_codegen_cranelift* "$target_dir/"
40+
cp -a rust-toolchain scripts/config.sh scripts/cargo.sh "$target_dir"
4141

4242
if [[ "$build_sysroot" == "1" ]]; then
4343
echo "[BUILD] sysroot"
4444
export CG_CLIF_INCR_CACHE_DISABLED=1
4545
dir=$(pwd)
46-
cd $target_dir
47-
time $dir/build_sysroot/build_sysroot.sh
46+
cd "$target_dir"
47+
time "$dir/build_sysroot/build_sysroot.sh"
4848
fi

build_sysroot/build_sysroot.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dir=$(pwd)
1313
export RUSTC=$dir"/cg_clif_build_sysroot"
1414
export RUSTFLAGS=$RUSTFLAGS" --clif"
1515

16-
cd $(dirname "$0")
16+
cd "$(dirname "$0")"
1717

1818
# Cleanup for previous run
1919
# v Clean target dir except for build scripts and incremental cache
@@ -28,12 +28,12 @@ if [[ "$1" != "--debug" ]]; then
2828
sysroot_channel='release'
2929
# FIXME Enable incremental again once rust-lang/rust#74946 is fixed
3030
# FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore
31-
CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target $TARGET_TRIPLE --release
31+
CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target "$TARGET_TRIPLE" --release
3232
else
3333
sysroot_channel='debug'
34-
cargo build --target $TARGET_TRIPLE
34+
cargo build --target "$TARGET_TRIPLE"
3535
fi
3636

3737
# Copy files to sysroot
38-
mkdir -p $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
39-
cp -a target/$TARGET_TRIPLE/$sysroot_channel/deps/* $dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
38+
mkdir -p "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"
39+
cp -a "target/$TARGET_TRIPLE/$sysroot_channel/deps/"* "$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib/"

build_sysroot/prepare_sysroot_src.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#!/bin/bash
22
set -e
3-
cd $(dirname "$0")
3+
cd "$(dirname "$0")"
44

5-
SRC_DIR=$(dirname $(rustup which rustc))"/../lib/rustlib/src/rust/"
5+
SRC_DIR="$(dirname "$(rustup which rustc)")/../lib/rustlib/src/rust/"
66
DST_DIR="sysroot_src"
77

8-
if [ ! -e $SRC_DIR ]; then
8+
if [ ! -e "$SRC_DIR" ]; then
99
echo "Please install rust-src component"
1010
exit 1
1111
fi
1212

1313
rm -rf $DST_DIR
1414
mkdir -p $DST_DIR/library
15-
cp -a $SRC_DIR/library $DST_DIR/
15+
cp -a "$SRC_DIR/library" $DST_DIR/
1616

1717
pushd $DST_DIR
1818
echo "[GIT] init"
@@ -22,8 +22,8 @@ git add .
2222
echo "[GIT] commit"
2323
git commit -m "Initial commit" -q
2424
for file in $(ls ../../patches/ | grep -v patcha); do
25-
echo "[GIT] apply" $file
26-
git apply ../../patches/$file
25+
echo "[GIT] apply" "$file"
26+
git apply ../../patches/"$file"
2727
git add -A
2828
git commit --no-gpg-sign -m "Patch $file"
2929
done

scripts/cargo.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
22

33
dir=$(dirname "$0")
4-
source $dir/config.sh
4+
source "$dir/config.sh"
55

66
# read nightly compiler from rust-toolchain file
7-
TOOLCHAIN=$(cat $dir/rust-toolchain)
7+
TOOLCHAIN=$(cat "$dir/rust-toolchain")
88

99
cmd=$1
1010
shift || true
1111

1212
if [[ "$cmd" = "jit" ]]; then
13-
cargo +${TOOLCHAIN} rustc $@ -- --jit
13+
cargo "+${TOOLCHAIN}" rustc "$@" -- --jit
1414
else
15-
cargo +${TOOLCHAIN} $cmd $@
15+
cargo "+${TOOLCHAIN}" "$cmd" "$@"
1616
fi

scripts/config.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set -e
22

3-
unamestr=`uname`
3+
unamestr=$(uname)
44
if [[ "$unamestr" == 'Linux' ]]; then
55
dylib_ext='so'
66
elif [[ "$unamestr" == 'Darwin' ]]; then
@@ -39,19 +39,19 @@ echo
3939
export RUSTC_WRAPPER=
4040
fi
4141

42-
dir=$(cd $(dirname "$BASH_SOURCE"); pwd)
42+
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)
4343

4444
export RUSTC=$dir"/cg_clif"
4545
export RUSTFLAGS=$linker
4646
export RUSTDOCFLAGS=$linker' -Cpanic=abort -Zpanic-abort-tests '\
4747
'-Zcodegen-backend='$dir'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$dir'/sysroot'
4848

4949
# FIXME remove once the atomic shim is gone
50-
if [[ `uname` == 'Darwin' ]]; then
50+
if [[ $(uname) == 'Darwin' ]]; then
5151
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
5252
fi
5353

54-
export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib"
54+
export LD_LIBRARY_PATH="$dir:$(rustc --print sysroot)/lib:$dir/target/out:$dir/sysroot/lib/rustlib/$TARGET_TRIPLE/lib"
5555
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
5656

5757
export CG_CLIF_DISPLAY_CG_TIME=1

scripts/rustup.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ case $1 in
77
TOOLCHAIN=$(date +%Y-%m-%d)
88

99
echo "=> Installing new nightly"
10-
rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists
11-
echo nightly-${TOOLCHAIN} > rust-toolchain
10+
rustup toolchain install --profile minimal "nightly-${TOOLCHAIN}" # Sanity check to see if the nightly exists
11+
echo "nightly-${TOOLCHAIN}" > rust-toolchain
1212
rustup component add rustfmt || true
1313

1414
echo "=> Uninstalling all old nighlies"
15-
for nightly in $(rustup toolchain list | grep nightly | grep -v $TOOLCHAIN | grep -v nightly-x86_64); do
16-
rustup toolchain uninstall $nightly
15+
for nightly in $(rustup toolchain list | grep nightly | grep -v "$TOOLCHAIN" | grep -v nightly-x86_64); do
16+
rustup toolchain uninstall "$nightly"
1717
done
1818

1919
./clean_all.sh
@@ -30,9 +30,9 @@ case $1 in
3030
cg_clif=$(pwd)
3131
pushd ../rust
3232
branch=update_cg_clif-$(date +%Y-%m-%d)
33-
git checkout -b $branch
33+
git checkout -b "$branch"
3434
git subtree pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master
35-
git push -u my $branch
35+
git push -u my "$branch"
3636
popd
3737
;;
3838
*)

scripts/test_bootstrap.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
cd $(dirname "$0")/../
4+
cd "$(dirname "$0")/../"
55

66
./build.sh
77
source build/config.sh
@@ -11,7 +11,7 @@ git clone https://github.com/rust-lang/rust.git || true
1111
pushd rust
1212
git fetch
1313
git checkout -- .
14-
git checkout $(rustc -V | cut -d' ' -f3 | tr -d '(')
14+
git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')"
1515

1616
git apply - <<EOF
1717
diff --git a/.gitmodules b/.gitmodules

scripts/tests.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,63 @@ set -e
44

55
source build/config.sh
66
export CG_CLIF_INCR_CACHE_DISABLED=1
7-
MY_RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2"
7+
MY_RUSTC="$RUSTC $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2"
88

99
function no_sysroot_tests() {
1010
echo "[BUILD] mini_core"
11-
$MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
11+
$MY_RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target "$TARGET_TRIPLE"
1212

1313
echo "[BUILD] example"
14-
$MY_RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
14+
$MY_RUSTC example/example.rs --crate-type lib --target "$TARGET_TRIPLE"
1515

1616
if [[ "$JIT_SUPPORTED" = "1" ]]; then
1717
echo "[JIT] mini_core_hello_world"
18-
CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE
18+
CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
1919
else
2020
echo "[JIT] mini_core_hello_world (skipped)"
2121
fi
2222

2323
echo "[AOT] mini_core_hello_world"
24-
$MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE
24+
$MY_RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target "$TARGET_TRIPLE"
2525
$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd
2626
# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd
2727

2828
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
29-
$MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
29+
$MY_RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target "$TARGET_TRIPLE"
3030
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
3131
}
3232

3333
function base_sysroot_tests() {
3434
echo "[AOT] alloc_example"
35-
$MY_RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE
35+
$MY_RUSTC example/alloc_example.rs --crate-type bin --target "$TARGET_TRIPLE"
3636
$RUN_WRAPPER ./target/out/alloc_example
3737

3838
if [[ "$JIT_SUPPORTED" = "1" ]]; then
3939
echo "[JIT] std_example"
40-
$MY_RUSTC --jit example/std_example.rs --target $HOST_TRIPLE
40+
$MY_RUSTC --jit example/std_example.rs --target "$HOST_TRIPLE"
4141
else
4242
echo "[JIT] std_example (skipped)"
4343
fi
4444

4545
echo "[AOT] dst_field_align"
4646
# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed.
47-
$MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE
47+
$MY_RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target "$TARGET_TRIPLE"
4848
$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false)
4949

5050
echo "[AOT] std_example"
51-
$MY_RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE
51+
$MY_RUSTC example/std_example.rs --crate-type bin --target "$TARGET_TRIPLE"
5252
$RUN_WRAPPER ./target/out/std_example arg
5353

5454
echo "[AOT] subslice-patterns-const-eval"
55-
$MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
55+
$MY_RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
5656
$RUN_WRAPPER ./target/out/subslice-patterns-const-eval
5757

5858
echo "[AOT] track-caller-attribute"
59-
$MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE
59+
$MY_RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target "$TARGET_TRIPLE"
6060
$RUN_WRAPPER ./target/out/track-caller-attribute
6161

6262
echo "[AOT] mod_bench"
63-
$MY_RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE
63+
$MY_RUSTC example/mod_bench.rs --crate-type bin --target "$TARGET_TRIPLE"
6464
$RUN_WRAPPER ./target/out/mod_bench
6565

6666
pushd rand
@@ -73,13 +73,13 @@ function extended_sysroot_tests() {
7373
pushd simple-raytracer
7474
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
7575
echo "[BENCH COMPILE] ebobby/simple-raytracer"
76-
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \
76+
hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
7777
"RUSTC=rustc RUSTFLAGS='' cargo build" \
7878
"../build/cargo.sh build"
7979

8080
echo "[BENCH RUN] ebobby/simple-raytracer"
8181
cp ./target/debug/main ./raytracer_cg_clif
82-
hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif
82+
hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_clif
8383
else
8484
echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)"
8585
echo "[COMPILE] ebobby/simple-raytracer"

test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ set -e
33

44
export RUSTFLAGS="-Zrun_dsymutil=no"
55

6-
./build.sh --without-sysroot $@
6+
./build.sh --without-sysroot "$@"
77

88
rm -r target/out || true
99

1010
scripts/tests.sh no_sysroot
1111

12-
./build.sh $@
12+
./build.sh "$@"
1313

1414
scripts/tests.sh base_sysroot
1515
scripts/tests.sh extended_sysroot

0 commit comments

Comments
 (0)