Fix shellcheck warnings in shell scripts.

This commit is contained in:
Dan Gohman
2018-06-11 13:48:35 -07:00
parent c03d67a4ff
commit 967da59181
6 changed files with 24 additions and 28 deletions

View File

@@ -4,4 +4,4 @@ set -euo pipefail
# Check all sources with clippy. # Check all sources with clippy.
# In the cton-util crate (root dir) clippy will only work with nightly cargo - # In the cton-util crate (root dir) clippy will only work with nightly cargo -
# there is a bug where it will reject the commands passed to it by cargo 0.25.0 # there is a bug where it will reject the commands passed to it by cargo 0.25.0
cargo +nightly clippy --all exec cargo +nightly clippy --all

View File

@@ -3,7 +3,8 @@ set -euo pipefail
# Format all sources using rustfmt. # Format all sources using rustfmt.
cd $(dirname "$0") topdir=$(dirname "$0")
cd "$topdir"
# Make sure we can find rustfmt. # Make sure we can find rustfmt.
export PATH="$PATH:$HOME/.cargo/bin" export PATH="$PATH:$HOME/.cargo/bin"

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
cd $(dirname "$0") topdir=$(dirname "$0")
topdir="$(pwd)" cd "$topdir"
# All the cretonne-* crates have the same version number # All the cretonne-* crates have the same version number
version="0.9.0" version="0.9.0"
@@ -28,12 +28,6 @@ cargo update
echo git commit -a -m "\"Bump version to $version"\" echo git commit -a -m "\"Bump version to $version"\"
echo git push echo git push
for crate in entity codegen frontend native reader wasm module simplejit faerie umbrella ; do for crate in entity codegen frontend native reader wasm module simplejit faerie umbrella ; do
if [ "$crate" == "umbrella" ]; then
dir="cretonne"
else
dir="$crate"
fi
echo cargo publish --manifest-path "lib/$crate/Cargo.toml" echo cargo publish --manifest-path "lib/$crate/Cargo.toml"
done done
echo echo

View File

@@ -15,18 +15,18 @@ set -euo pipefail
export PYTHONDONTWRITEBYTECODE=1 export PYTHONDONTWRITEBYTECODE=1
# Repository top-level directory. # Repository top-level directory.
cd $(dirname "$0") topdir=$(dirname "$0")
topdir=$(pwd) cd "$topdir"
function banner { function banner {
echo "====== $@ ======" echo "====== $* ======"
} }
# Run rustfmt if we have it. # Run rustfmt if we have it.
banner "Rust formatting" banner "Rust formatting"
if command -v rustfmt > /dev/null; then if type rustfmt > /dev/null; then
# In newer versions of rustfmt, replace --write-mode=diff with --check. # In newer versions of rustfmt, replace --write-mode=diff with --check.
if ! $topdir/format-all.sh --write-mode=diff ; then if ! "$topdir/format-all.sh" --write-mode=diff ; then
echo "Formatting diffs detected! Run \"cargo fmt --all\" to correct." echo "Formatting diffs detected! Run \"cargo fmt --all\" to correct."
exit 1 exit 1
fi fi
@@ -39,16 +39,16 @@ else
fi fi
# Check if any Python files have changed since we last checked them. # Check if any Python files have changed since we last checked them.
tsfile=$topdir/target/meta-checked tsfile="$topdir/target/meta-checked"
if [ -f $tsfile ]; then if [ -f "$tsfile" ]; then
needcheck=$(find $topdir/lib/codegen/meta -name '*.py' -newer $tsfile) needcheck=$(find "$topdir/lib/codegen/meta" -name '*.py' -newer "$tsfile")
else else
needcheck=yes needcheck=yes
fi fi
if [ -n "$needcheck" ]; then if [ -n "$needcheck" ]; then
banner "$(python --version 2>&1), $(python3 --version 2>&1)" banner "$(python --version 2>&1), $(python3 --version 2>&1)"
$topdir/lib/codegen/meta/check.sh "$topdir/lib/codegen/meta/check.sh"
touch $tsfile || echo no target directory touch "$tsfile" || echo no target directory
fi fi
# Make sure the code builds in release mode. # Make sure the code builds in release mode.
@@ -69,8 +69,8 @@ cargo doc
# Run clippy if we have it. # Run clippy if we have it.
banner "Rust linter" banner "Rust linter"
if $topdir/check-clippy.sh; then if "$topdir/check-clippy.sh"; then
$topdir/clippy-all.sh --write-mode=diff "$topdir/clippy-all.sh" --write-mode=diff
else else
echo "\`cargo +nightly install clippy\` for optional rust linting" echo "\`cargo +nightly install clippy\` for optional rust linting"
fi fi
@@ -85,7 +85,7 @@ if rustup toolchain list | grep -q nightly; then
echo "installing cargo-fuzz" echo "installing cargo-fuzz"
cargo +nightly install cargo-fuzz cargo +nightly install cargo-fuzz
fi fi
ASAN_OPTIONS=detect_leaks=0 cargo +nightly fuzz run fuzz_translate_module $topdir/fuzz/corpus/fuzz_translate_module/ffaefab69523eb11935a9b420d58826c8ea65c4c ASAN_OPTIONS=detect_leaks=0 cargo +nightly fuzz run fuzz_translate_module "$topdir/fuzz/corpus/fuzz_translate_module/ffaefab69523eb11935a9b420d58826c8ea65c4c"
else else
echo "nightly toolchain not found, skipping fuzz target integration test" echo "nightly toolchain not found, skipping fuzz target integration test"
fi fi

View File

@@ -5,11 +5,11 @@ set -euo pipefail
# packages which support it. # packages which support it.
# Repository top-level directory. # Repository top-level directory.
cd $(dirname "$0") topdir=$(dirname "$0")
topdir=$(pwd) cd "$topdir"
function banner { function banner {
echo "====== $@ ======" echo "====== $* ======"
} }
# Test those packages which have no_std support. # Test those packages which have no_std support.

View File

@@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
cd $(dirname "$0") topdir=$(dirname "$0")
cd "$topdir"
function runif { function runif {
if command -v "$1" > /dev/null; then if type "$1" > /dev/null; then
echo " === $1 ===" echo " === $1 ==="
"$@" "$@"
else else