Skip to content

Commit d114847

Browse files
committed
fix(install): protect path with whitespaces using quotes and stop at the first error
1 parent 0bd7a06 commit d114847

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

install.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
23

34
echo "Let's get you set up with Rustlings!"
45

@@ -100,8 +101,8 @@ function vercomp() {
100101

101102
RustVersion=$(rustc --version | cut -d " " -f 2)
102103
MinRustVersion=1.39
103-
vercomp $RustVersion $MinRustVersion
104-
if [ $? -eq 2 ]
104+
vercomp "$RustVersion" $MinRustVersion || ec=$?
105+
if [ ${ec:-0} -eq 2 ]
105106
then
106107
echo "ERROR: Rust version is too old: $RustVersion - needs at least $MinRustVersion"
107108
echo "Please update Rust with 'rustup update'"
@@ -112,9 +113,9 @@ fi
112113

113114
Path=${1:-rustlings/}
114115
echo "Cloning Rustlings at $Path..."
115-
git clone -q https://github.com/rust-lang/rustlings $Path
116+
git clone -q https://github.com/rust-lang/rustlings "$Path"
116117

117-
cd $Path
118+
cd "$Path"
118119

119120
Version=$(curl -s https://api.github.com/repos/rust-lang/rustlings/releases/latest | ${PY} -c "import json,sys;obj=json.load(sys.stdin);print(obj['tag_name']);")
120121
CargoBin="${CARGO_HOME:-$HOME/.cargo}/bin"

0 commit comments

Comments
 (0)