From 94c5c9667c786e05a635787e803d2cf7e22de73a Mon Sep 17 00:00:00 2001 From: David Beckingsale Date: Thu, 31 Jul 2014 13:42:34 -0700 Subject: Added inital module support --- share/spack/setup-env.bash | 49 +++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'share') diff --git a/share/spack/setup-env.bash b/share/spack/setup-env.bash index e22a259167..c23a5acab4 100755 --- a/share/spack/setup-env.bash +++ b/share/spack/setup-env.bash @@ -65,8 +65,38 @@ function spack { # Filter out use and unuse. For any other commands, just run the # command. case $_spack_subcommand in - "use") ;; - "unuse") ;; + "use"|"unuse") + # Shift any other args for use off before parsing spec. + _spack_use_args="" + if [[ "$1" =~ ^- ]]; then + _spack_use_args="$1"; shift + _spack_spec="$@" + fi + + # Here the user has run use or unuse with a spec. Find a matching + # spec with a dotkit using spack dotkit, then use or unuse the + # result. If spack dotkit comes back with an error, do nothing. + if _spack_full_spec=$(command spack dotkit $_spack_spec); then + $_spack_subcommand $_spack_use_args $_spack_full_spec + fi + return + ;; + "load"|"unload") + # Shift any other args for module off before parsing spec. + _spack_module_args="" + if [[ "$1" =~ ^- ]]; then + _spack_module_args="$1"; shift + _spack_spec="$@" + fi + + # Here the user has run use or unuse with a spec. Find a matching + # spec with a dotkit using spack dotkit, then use or unuse the + # result. If spack dotkit comes back with an error, do nothing. + if _spack_full_spec=$(command spack tclmodule $_spack_spec); then + $_spack_subcommand $_spack_module_args $_spack_full_spec + fi + return + ;; *) command spack $_spack_subcommand "$@" return @@ -79,19 +109,6 @@ function spack { return fi - # Shift any other args for use off before parsing spec. - _spack_use_args="" - if [[ "$1" =~ ^- ]]; then - _spack_use_args="$1"; shift - _spack_spec="$@" - fi - - # Here the user has run use or unuse with a spec. Find a matching - # spec with a dotkit using spack dotkit, then use or unuse the - # result. If spack dotkit comes back with an error, do nothing. - if _spack_full_spec=$(command spack dotkit $_spack_spec); then - $_spack_subcommand $_spack_use_args $_spack_full_spec - fi } ######################################################################## @@ -128,5 +145,5 @@ _spack_share_dir="$(dirname ${BASH_SOURCE[0]})" _spack_prefix="$(dirname $(dirname $_spack_share_dir))" _spack_pathadd DK_NODE "$_spack_share_dir/dotkit" +_spack_pathadd MODULEPATH "$_spack_share_dir/modules" _spack_pathadd PATH "$_spack_prefix/bin" - -- cgit v1.2.3-70-g09d2