summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/spack/csh/spack.csh42
-rwxr-xr-xshare/spack/setup-env.csh5
-rwxr-xr-xshare/spack/setup-env.sh22
3 files changed, 52 insertions, 17 deletions
diff --git a/share/spack/csh/spack.csh b/share/spack/csh/spack.csh
index 2f6b96f4eb..169e9878bf 100644
--- a/share/spack/csh/spack.csh
+++ b/share/spack/csh/spack.csh
@@ -22,14 +22,28 @@
# avoids the need to come up with a user-friendly naming scheme for
# spack dotfiles.
########################################################################
+# accumulate initial flags for main spack command
+set _sp_flags = ""
+while ( $#_sp_args > 0 )
+ if ( "$_sp_args[1]" !~ "-*" ) break
+ set _sp_flags = "$_sp_flags $_sp_args[1]"
+ shift _sp_args
+end
+
+# h and V flags don't require further output parsing.
+if ( "$_sp_flags" =~ *h* || "$_sp_flags" =~ *V* ) then
+ \spack $_sp_flags $_sp_args
+ goto _sp_end
+endif
+
# Set up args -- we want a subcommand and a spec.
-set _sp_subcommand="";
-set _sp_spec="";
-[ $#_sp_args -gt 0 ] && set _sp_subcommand = ($_sp_args[1]);
-[ $#_sp_args -gt 1 ] && set _sp_spec = ($_sp_args[2-]);
+set _sp_subcommand=""
+set _sp_spec=""
+[ $#_sp_args -gt 0 ] && set _sp_subcommand = ($_sp_args[1])
+[ $#_sp_args -gt 1 ] && set _sp_spec = ($_sp_args[2-])
# Figure out what type of module we're running here.
-set _sp_modtype = "";
+set _sp_modtype = ""
switch ($_sp_subcommand)
case use:
case unuse:
@@ -48,12 +62,12 @@ case unload:
case use:
case unuse:
set _sp_modtype = dotkit
- set _sp_sh_cmd = $_sp_subcommand
+ set _sp_sh_cmd = ( "`alias $_sp_subcommand'" )
breaksw
case load:
case unload:
set _sp_modtype = tcl
- set _sp_sh_cmd = ( module $_sp_subcommand )
+ set _sp_sh_cmd = ( "`alias module`" $_sp_subcommand )
breaksw
endsw
@@ -61,11 +75,17 @@ case unload:
# spec using 'spack module find', then use the appropriate module
# tool's commands to add/remove the result from the environment.
# If spack module command comes back with an error, do nothing.
- if { set _sp_full_spec = `command spack module find $_sp_modtype $_sp_spec` } then
- echo $_sp_sh_cmd $_sp_module_args $_sp_full_spec
+ set _sp_full_spec = ""
+ if { set _sp_full_spec = `\spack module find $_sp_modtype $_sp_spec` } then
+ $_sp_sh_cmd $_sp_module_args $_sp_full_spec
endif
+ breaksw
+
default:
- command spack $_sp_args
+ \spack $_sp_args
+ breaksw
endsw
-unset _sp_args _sp_full_spec _sp_modtype _sp_module_args _sp_sh_cmd _sp_spec _sp_subcommand
+_sp_end:
+unset _sp_args _sp_full_spec _sp_modtype _sp_module_args
+unset _sp_sh_cmd _sp_spec _sp_subcommand _sp_flags
diff --git a/share/spack/setup-env.csh b/share/spack/setup-env.csh
index e3243e40b2..cc12eae82f 100755
--- a/share/spack/setup-env.csh
+++ b/share/spack/setup-env.csh
@@ -40,7 +40,8 @@ if ($?SPACK_ROOT) then
alias _spack_pathadd 'set _pa_args = (\!*) && source $_spack_share_dir/csh/spack_pathadd.csh'
# Set up modules and dotkit search paths in the user environment
- _spack_pathadd DK_NODE "$_spack_share_dir/dotkit"
- _spack_pathadd MODULEPATH "$_spack_share_dir/modules"
+ # TODO: fix SYS_TYPE to something non-LLNL-specific
+ _spack_pathadd DK_NODE "$_spack_share_dir/dotkit/$SYS_TYPE"
+ _spack_pathadd MODULEPATH "$_spack_share_dir/modules/$SYS_TYPE"
_spack_pathadd PATH "$SPACK_ROOT/bin"
endif
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 7cadc6f202..0142e04817 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -56,6 +56,19 @@
# spack dotfiles.
########################################################################
function spack {
+ # accumulate initial flags for main spack command
+ _sp_flags=""
+ while [[ "$1" =~ ^- ]]; do
+ _sp_flags="$_sp_flags $1"
+ shift
+ done
+
+ # h and V flags don't require further output parsing.
+ if [[ "$_sp_flags" =~ *h* || "$_sp_flags" =~ *V* ]]; then
+ command spack $_sp_flags "$@"
+ return
+ fi
+
_sp_subcommand=$1; shift
_sp_spec="$@"
@@ -88,13 +101,13 @@ function spack {
# spec using 'spack module find', then use the appropriate module
# tool's commands to add/remove the result from the environment.
# If spack module command comes back with an error, do nothing.
- if _sp_full_spec=$(command spack module find $_sp_modtype $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module find $_sp_modtype $_sp_spec); then
$_sp_sh_cmd $_sp_module_args $_sp_full_spec
fi
return
;;
*)
- command spack $_sp_subcommand $_sp_spec
+ command spack $_sp_flags $_sp_subcommand $_sp_spec
esac
}
@@ -145,6 +158,7 @@ fi
_sp_share_dir="$(dirname $_sp_source_file)"
_sp_prefix="$(dirname $(dirname $_sp_share_dir))"
-_spack_pathadd DK_NODE "$_sp_share_dir/dotkit"
-_spack_pathadd MODULEPATH "$_sp_share_dir/modules"
+# TODO: fix SYS_TYPE to something non-LLNL-specific
+_spack_pathadd DK_NODE "$_sp_share_dir/dotkit/$SYS_TYPE"
+_spack_pathadd MODULEPATH "$_sp_share_dir/modules/$SYS_TYPE"
_spack_pathadd PATH "$_sp_prefix/bin"