]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #4168 - lzutao:fix-script, r=flip1995
authorbors <bors@rust-lang.org>
Mon, 3 Jun 2019 09:39:23 +0000 (09:39 +0000)
committerbors <bors@rust-lang.org>
Mon, 3 Jun 2019 09:39:23 +0000 (09:39 +0000)
Do not install rustup-toolchain if it is in PATH

I find it quiet annoying because I manually build `rustup-toolchain-install-master`
and install it in `PATH` other than in `~/.cargo/bin`. So everytime I run the script,
it always reinstall `rustup-toolchain-install-master` for me.

changelog: none

setup-toolchain.sh

index f8d764b613271240c35853ba9d96bf013f93a205..c1c8366bf5e769a6106065d1f05091b904855a97 100755 (executable)
@@ -1,9 +1,12 @@
 #!/bin/bash
 # Set up the appropriate rustc toolchain
 
-cd $(dirname $0)
+cd "$(dirname "$0")"
+
+if ! command -v rustup-toolchain-install-master > /dev/null; then
+  cargo install rustup-toolchain-install-master --debug
+fi
 
-cargo install rustup-toolchain-install-master --debug || echo "rustup-toolchain-install-master already installed"
 RUSTC_HASH=$(git ls-remote https://github.com/rust-lang/rust.git master | awk '{print $1}')
-rustup-toolchain-install-master -f -n master $RUSTC_HASH
+rustup-toolchain-install-master -f -n master "$RUSTC_HASH"
 rustup override set master