summaryrefslogtreecommitdiff
path: root/share/spack/setup-env.sh
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-10-29 10:10:22 +0200
committerGitHub <noreply@github.com>2021-10-29 08:10:22 +0000
commit49034abd769af00ed85ca6583b83f1f36e42ce11 (patch)
tree1db3bce306a786d90a1b717827d3b013e7d971a9 /share/spack/setup-env.sh
parentf610b506cdad8b8717bcecc3d9138136a26fa6b8 (diff)
downloadspack-49034abd769af00ed85ca6583b83f1f36e42ce11.tar.gz
spack-49034abd769af00ed85ca6583b83f1f36e42ce11.tar.bz2
spack-49034abd769af00ed85ca6583b83f1f36e42ce11.tar.xz
spack-49034abd769af00ed85ca6583b83f1f36e42ce11.zip
Fix exit codes posix shell wrapper (#27012)
* Correct exit code in sh wrapper * Fix tests * SC2069
Diffstat (limited to 'share/spack/setup-env.sh')
-rwxr-xr-xshare/spack/setup-env.sh13
1 files changed, 8 insertions, 5 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 21bd696386..eb364a3809 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -136,7 +136,8 @@ _spack_shell_wrapper() {
command spack env activate "$@"
else
# Actual call to activate: source the output.
- eval $(command spack $_sp_flags env activate --sh "$@")
+ stdout="$(command spack $_sp_flags env activate --sh "$@")" || return
+ eval "$stdout"
fi
;;
deactivate)
@@ -157,7 +158,8 @@ _spack_shell_wrapper() {
command spack env deactivate -h
else
# No args: source the output of the command.
- eval $(command spack $_sp_flags env deactivate --sh)
+ stdout="$(command spack $_sp_flags env deactivate --sh)" || return
+ eval "$stdout"
fi
;;
*)
@@ -183,8 +185,8 @@ _spack_shell_wrapper() {
# Args contain --sh, --csh, or -h/--help: just execute.
command spack $_sp_flags $_sp_subcommand "$@"
else
- eval $(command spack $_sp_flags $_sp_subcommand --sh "$@" || \
- echo "return 1") # return 1 if spack command fails
+ stdout="$(command spack $_sp_flags $_sp_subcommand --sh "$@")" || return
+ eval "$stdout"
fi
;;
*)
@@ -363,7 +365,8 @@ if [ -z "${SPACK_SKIP_MODULES+x}" ]; then
_spack_pathadd PATH "${_sp_module_bin}"
fi;
else
- eval `spack --print-shell-vars sh`
+ stdout="$(command spack --print-shell-vars sh)" || return
+ eval "$stdout"
fi;