Small script fix (#2591)

# Objective
Prevent some possible problem
Found by IntelliJ IDEA

## Solution

Double quoting variable and exit on possible failure of cd command.
This commit is contained in:
Rémi Lauzier 2021-08-13 21:57:23 +00:00
parent b13472dae4
commit fafee8898e
2 changed files with 7 additions and 7 deletions

View File

@ -3,16 +3,16 @@
duration='2' duration='2'
function wait_seconds() { perl -e 'alarm shift; exec @ARGV' "$@"; } function wait_seconds() { perl -e 'alarm shift; exec @ARGV' "$@"; }
run_example() { run_example() {
cargo build --example $1 cargo build --example "$1"
wait_seconds "$duration" cargo run --example $1 wait_seconds "$duration" cargo run --example "$1"
} }
example_list="$(cargo build --example 2>&1)" example_list="$(cargo build --example 2>&1)"
example_list=${example_list//$'\n'/} example_list=${example_list//$'\n'/}
example_list="${example_list#error\: \"--example\" takes one argument.Available examples\: }" example_list="${example_list#error\: \"--example\" takes one argument.Available examples\: }"
echo $example_list echo "$example_list"
for example in $example_list for example in $example_list
do do
echo "Running example: $example" echo "Running example: $example"
run_example $example run_example "$example"
done done

View File

@ -37,9 +37,9 @@ cd crates
for crate in "${crates[@]}" for crate in "${crates[@]}"
do do
echo "Publishing ${crate}" echo "Publishing ${crate}"
(cd $crate; cargo publish --no-verify) (cd "$crate"; cargo publish --no-verify)
sleep 20 sleep 20
done done
cd .. cd ..
cargo publish cargo publish