about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2015-04-22 14:52:35 -0700
committerBrian Anderson <banderson@mozilla.com>2015-04-22 14:52:35 -0700
commit0c196fd44c08a184bffb37b91cb538d5d3ebd330 (patch)
tree8e885bea1bb0cce2f4534b0157451313d3512ebd
parent93b7b411378ac3b5b427cb05ecb96d0bc11eb124 (diff)
downloadrust-0c196fd44c08a184bffb37b91cb538d5d3ebd330.tar.gz
rust-0c196fd44c08a184bffb37b91cb538d5d3ebd330.zip
configure: Fix CDPATH bug
-rwxr-xr-xconfigure11
1 files changed, 10 insertions, 1 deletions
diff --git a/configure b/configure
index 18fef588936..fc8d57999ff 100755
--- a/configure
+++ b/configure
@@ -337,6 +337,15 @@ to_gnu_triple() {
     esac
 }
 
+# Prints the absolute path of a directory to stdout
+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. Route `cd`'s output to /dev/null
+    # for good measure.
+    (unset CDPATH && cd "$_path" > /dev/null && pwd)
+}
+
 msg "looking for configure programs"
 need_cmd cmp
 need_cmd mkdir
@@ -509,7 +518,7 @@ fi
 
 DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}"
 
-CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
+CFG_SRC_DIR="$(abs_path $(dirname $0))/"
 CFG_BUILD_DIR="$(pwd)/"
 CFG_SELF="$0"
 CFG_CONFIGURE_ARGS="$@"