diff --git a/changelog/dpath.dd b/changelog/dpath.dd new file mode 100644 index 00000000..d5446358 --- /dev/null +++ b/changelog/dpath.dd @@ -0,0 +1,5 @@ +The `install.sh` script now respects the `$DPATH` environment variable + +The `$DPATH` environment variable can be set on any system to make the install location of the install.sh script as well as other D related tools like DUB to store their cache files, dependencies, installed compilers, etc. + +This way you can change where all the D tools are installed and keep a clean home folder. diff --git a/script/install.sh b/script/install.sh index 81970369..b534b325 100755 --- a/script/install.sh +++ b/script/install.sh @@ -176,13 +176,21 @@ GET_PATH_AUTO_INSTALL=0 GET_PATH_COMPILER=dc # Set a default install path depending on the POSIX/Windows environment. if posix_terminal; then - ROOT=~/dlang + if [ -z "$DPATH" ]; then + ROOT=~/dlang + else + ROOT="$DPATH/dlang" + fi else - # Default to a ROOT that is outside the POSIX-like environment. - if [ -z "$USERPROFILE" ]; then - fatal '%USERPROFILE% should not be empty on Windows.'; + if [ -z "$DPATH" ]; then + # Default to a ROOT that is outside the POSIX-like environment. + if [ -z "$USERPROFILE" ]; then + fatal '%USERPROFILE% should not be empty on Windows.'; + fi + ROOT=$(posix_path "$USERPROFILE")/dlang + else + ROOT=$(posix_path "$DPATH")/dlang fi - ROOT=$(posix_path "$USERPROFILE")/dlang fi TMP_ROOT= DUB_VERSION=