summaryrefslogtreecommitdiff
path: root/gen-installer.sh
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-04-22 10:48:52 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-22 10:48:52 -0700
commit47fbf56ec1d01b359138664ec7e7634c1013b37d (patch)
treef8e01ef0974ed3ff6dcbeae41361892a7554c797 /gen-installer.sh
parenteb969cfa7e610a74586bcee318db9f473358c7a0 (diff)
parente0ef9caac8fdea7c1d39e403f24e7a6d85479371 (diff)
downloadrust-installer-47fbf56ec1d01b359138664ec7e7634c1013b37d.tar.gz
Merge pull request #32 from brson/next
Don't break when CDPATH is set. Fixes #31
Diffstat (limited to 'gen-installer.sh')
-rwxr-xr-xgen-installer.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/gen-installer.sh b/gen-installer.sh
index 3155ed2..8c8cc7d 100755
--- a/gen-installer.sh
+++ b/gen-installer.sh
@@ -204,6 +204,13 @@ validate_opt () {
done
}
+abs_path() {
+ local path="$1"
+ # Unset CDPATH because it causes havok: it makes the destination unpredictable
+ # and triggers 'cd' to print the path to stdout.
+ (unset CDPATH && cd "$path" && pwd)
+}
+
msg "looking for programs"
msg
@@ -256,9 +263,7 @@ fi
step_msg "validating arguments"
validate_opt
-# Redirect output of cd command, as it can display the new path when
-# CDPATH is set in bash (which is used for /bin/sh, at least on OS X).
-src_dir="$(cd $(dirname "$0") > /dev/null && pwd)"
+src_dir="$(abs_path $(dirname "$0"))"
rust_installer_version=`cat "$src_dir/rust-installer-version"`