spack-shell.patch 918 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index b983299..e19aa76 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -199,12 +199,17 @@ _spack_pathadd PATH       "${_sp_prefix%/}/bin"
 export SPACK_ROOT=${_sp_prefix}
 
 #
-# Determine which shell is being used
+# Try to determine which shell is being used if
+# SPACK_SHELL has not already been set by the user.
+# This variable is used for the environment-modules
+# 'module' function/command to envoke 'modulecmd' with
+# the correct shell.
 #
 function _spack_determine_shell() {
-	ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename
+        ps -p $$ | tail -n 1 | awk '{print $4}' | sed 's/^-//' | xargs basename
 }
-export SPACK_SHELL=$(_spack_determine_shell)
+SPACK_SHELL=${SPACK_SHELL:-$(_spack_determine_shell)}
+export SPACK_SHELL
 
 #
 # Check whether a function of the given name is defined