Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix shellcheck warnings in shell scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Jun 12, 2018
1 parent 110dccd commit 195adea
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion clippy-all.sh
Expand Up @@ -4,4 +4,4 @@ set -euo pipefail
# Check all sources with clippy.
# 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
cargo +nightly clippy --all
exec cargo +nightly clippy --all
3 changes: 2 additions & 1 deletion format-all.sh
Expand Up @@ -3,7 +3,8 @@ set -euo pipefail

# Format all sources using rustfmt.

cd $(dirname "$0")
topdir=$(dirname "$0")
cd "$topdir"

# Make sure we can find rustfmt.
export PATH="$PATH:$HOME/.cargo/bin"
Expand Down
5 changes: 3 additions & 2 deletions lib/codegen/meta/check.sh
@@ -1,9 +1,10 @@
#!/bin/bash
set -euo pipefail
cd $(dirname "$0")
topdir=$(dirname "$0")
cd "$topdir"

function runif {
if command -v "$1" > /dev/null; then
if type "$1" > /dev/null; then
echo " === $1 ==="
"$@"
else
Expand Down
10 changes: 2 additions & 8 deletions publish-all.sh
@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail
cd $(dirname "$0")
topdir="$(pwd)"
topdir=$(dirname "$0")
cd "$topdir"

# All the cretonne-* crates have the same version number
version="0.9.0"
Expand All @@ -28,12 +28,6 @@ cargo update
echo git commit -a -m "\"Bump version to $version"\"
echo git push
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"
done
echo
Expand Down
26 changes: 13 additions & 13 deletions test-all.sh
Expand Up @@ -15,18 +15,18 @@ set -euo pipefail
export PYTHONDONTWRITEBYTECODE=1

# Repository top-level directory.
cd $(dirname "$0")
topdir=$(pwd)
topdir=$(dirname "$0")
cd "$topdir"

function banner {
echo "====== $@ ======"
echo "====== $* ======"
}

# Run rustfmt if we have it.
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.
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."
exit 1
fi
Expand All @@ -39,16 +39,16 @@ else
fi

# Check if any Python files have changed since we last checked them.
tsfile=$topdir/target/meta-checked
if [ -f $tsfile ]; then
needcheck=$(find $topdir/lib/codegen/meta -name '*.py' -newer $tsfile)
tsfile="$topdir/target/meta-checked"
if [ -f "$tsfile" ]; then
needcheck=$(find "$topdir/lib/codegen/meta" -name '*.py' -newer "$tsfile")
else
needcheck=yes
fi
if [ -n "$needcheck" ]; then
banner "$(python --version 2>&1), $(python3 --version 2>&1)"
$topdir/lib/codegen/meta/check.sh
touch $tsfile || echo no target directory
"$topdir/lib/codegen/meta/check.sh"
touch "$tsfile" || echo no target directory
fi

# Make sure the code builds in release mode.
Expand All @@ -69,8 +69,8 @@ cargo doc

# Run clippy if we have it.
banner "Rust linter"
if $topdir/check-clippy.sh; then
$topdir/clippy-all.sh --write-mode=diff
if "$topdir/check-clippy.sh"; then
"$topdir/clippy-all.sh" --write-mode=diff
else
echo "\`cargo +nightly install clippy\` for optional rust linting"
fi
Expand All @@ -85,7 +85,7 @@ if rustup toolchain list | grep -q nightly; then
echo "installing cargo-fuzz"
cargo +nightly install cargo-fuzz
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
echo "nightly toolchain not found, skipping fuzz target integration test"
fi
Expand Down
6 changes: 3 additions & 3 deletions test-no_std.sh
Expand Up @@ -5,11 +5,11 @@ set -euo pipefail
# packages which support it.

# Repository top-level directory.
cd $(dirname "$0")
topdir=$(pwd)
topdir=$(dirname "$0")
cd "$topdir"

function banner {
echo "====== $@ ======"
echo "====== $* ======"
}

# Test those packages which have no_std support.
Expand Down

0 comments on commit 195adea

Please sign in to comment.