summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorbecker33 <becker33@llnl.gov>2016-07-15 14:23:51 -0700
committerGitHub <noreply@github.com>2016-07-15 14:23:51 -0700
commit36f818b9fb4e43a3010bfe22e1fa63d13489bba8 (patch)
tree3fa314f45da96590d74b0745b4a0afc67a66a5aa /share
parentc0be585b67a01fd751a06131857b51f5649a8dc8 (diff)
parent64d91943ec3773a539ef39be4e9ab5ab132df01a (diff)
downloadspack-36f818b9fb4e43a3010bfe22e1fa63d13489bba8.tar.gz
spack-36f818b9fb4e43a3010bfe22e1fa63d13489bba8.tar.bz2
spack-36f818b9fb4e43a3010bfe22e1fa63d13489bba8.tar.xz
spack-36f818b9fb4e43a3010bfe22e1fa63d13489bba8.zip
Merge pull request #1246 from suraia/improve-shell-integration
Improve shell integration.
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/setup-env.sh28
1 files changed, 20 insertions, 8 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 8aa259cf15..19206255db 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -57,6 +57,11 @@
########################################################################
function spack {
+ # Zsh does not do word splitting by default, this enables it for this function only
+ if [ -n "$ZSH_VERSION" ]; then
+ emulate -L sh
+ fi
+
# save raw arguments into an array before butchering them
args=( "$@" )
@@ -93,11 +98,18 @@ function spack {
;;
"use"|"unuse"|"load"|"unload")
# Shift any other args for use off before parsing spec.
+ _sp_subcommand_args=""
_sp_module_args=""
- if [[ "$1" =~ ^- ]]; then
- _sp_module_args="$1"; shift
- _sp_spec="$@"
- fi
+ while [[ "$1" =~ ^- ]]; do
+ if [ "$1" = "-r" -o "$1" = "--dependencies" ]; then
+ _sp_subcommand_args="$_sp_subcommand_args $1"
+ else
+ _sp_module_args="$_sp_module_args $1"
+ fi
+ shift
+ done
+
+ _sp_spec="$@"
# Here the user has run use or unuse with a spec. Find a matching
# spec using 'spack module find', then use the appropriate module
@@ -105,19 +117,19 @@ function spack {
# If spack module command comes back with an error, do nothing.
case $_sp_subcommand in
"use")
- if _sp_full_spec=$(command spack $_sp_flags module find dotkit $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module find $_sp_subcommand_args dotkit $_sp_spec); then
use $_sp_module_args $_sp_full_spec
fi ;;
"unuse")
- if _sp_full_spec=$(command spack $_sp_flags module find dotkit $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module find $_sp_subcommand_args dotkit $_sp_spec); then
unuse $_sp_module_args $_sp_full_spec
fi ;;
"load")
- if _sp_full_spec=$(command spack $_sp_flags module find tcl $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module find $_sp_subcommand_args tcl $_sp_spec); then
module load $_sp_module_args $_sp_full_spec
fi ;;
"unload")
- if _sp_full_spec=$(command spack $_sp_flags module find tcl $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module find $_sp_subcommand_args tcl $_sp_spec); then
module unload $_sp_module_args $_sp_full_spec
fi ;;
esac