environment shell: fix spack load
(#7747)
Fix `spack load` with extended packe specifications those includes spaces. Solved by using perfectly parameter forwarding via temporary array. example: ``` $ spack install zlib $ spack install zlib cppflags='-O3 -march=native' $ spack install zlib cppflags='-O2 -march=native' $ spack find -d -L -f zlib ==> 3 installed packages. -- linux-linuxmint18-x86_64 / gcc@5.4.0 ------------------------- k5hg4kkxiutkfl6n53ogz5wnlbdrsdtf zlib@1.2.11%gcc mse2fyzdxciszdhiqi4b5kl6fxkps3fh zlib@1.2.11%gcc cppflags="-O2 -march=native" vrnvj2fikcbxqxrymctnlpmud7wbuahk zlib@1.2.11%gcc cppflags="-O3 -march=native" $ spack load zlib cppflags='-O3 -march=native' ==> Error: Unexpected token ['zlib', 'cppflags=-O3', '-march=native'] ```
This commit is contained in:

committed by
Todd Gamblin

parent
f7da156879
commit
caa0c5c687
@@ -81,7 +81,7 @@ function spack {
|
||||
fi
|
||||
|
||||
_sp_subcommand=$1; shift
|
||||
_sp_spec="$@"
|
||||
_sp_spec=("$@")
|
||||
|
||||
# Filter out use and unuse. For any other commands, just run the
|
||||
# command.
|
||||
@@ -113,7 +113,7 @@ function spack {
|
||||
shift
|
||||
done
|
||||
|
||||
_sp_spec="$@"
|
||||
_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
|
||||
@@ -121,19 +121,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 loads --input-only $_sp_subcommand_args --module-type dotkit $_sp_spec); then
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit "${_sp_spec[@]}"); then
|
||||
use $_sp_module_args $_sp_full_spec
|
||||
fi ;;
|
||||
"unuse")
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit $_sp_spec); then
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit "${_sp_spec[@]}"); then
|
||||
unuse $_sp_module_args $_sp_full_spec
|
||||
fi ;;
|
||||
"load")
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl $_sp_spec); then
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl "${_sp_spec[@]}"); then
|
||||
module load $_sp_module_args $_sp_full_spec
|
||||
fi ;;
|
||||
"unload")
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl $_sp_spec); then
|
||||
if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl "${_sp_spec[@]}"); then
|
||||
module unload $_sp_module_args $_sp_full_spec
|
||||
fi ;;
|
||||
esac
|
||||
|
Reference in New Issue
Block a user