summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorpaulanda <40282207+paulanda@users.noreply.github.com>2019-04-16 13:33:02 -0600
committerPeter Scheibel <scheibel1@llnl.gov>2019-04-16 12:33:02 -0700
commit88cc895a7067dc6b7662755796a7cd749f71aee2 (patch)
tree26ae63c6aee74ef796af10f31b2f427419e29203 /share
parent9a79a2345d20a8da871b1d12d0a49f9470e8530d (diff)
downloadspack-88cc895a7067dc6b7662755796a7cd749f71aee2.tar.gz
spack-88cc895a7067dc6b7662755796a7cd749f71aee2.tar.bz2
spack-88cc895a7067dc6b7662755796a7cd749f71aee2.tar.xz
spack-88cc895a7067dc6b7662755796a7cd749f71aee2.zip
setup-env.sh: fix zsh compatibility error (#11153)
Still look for BASH_SOURCE[0] first, but if it's not set, _sp_source_file is initialized to an empty value addressing the unset parameter error (line 217).
Diffstat (limited to 'share')
-rwxr-xr-xshare/spack/setup-env.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 3698bb35b0..3c4342d852 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -214,10 +214,10 @@ fi
# Figure out where this file is. Below code needs to be portable to
# bash and zsh.
#
-_sp_source_file="${BASH_SOURCE[0]}" # Bash's location of last sourced file.
+_sp_source_file="${BASH_SOURCE[0]:-}" # Bash's location of last sourced file.
if [ -z "$_sp_source_file" ]; then
- _sp_source_file="$0:A" # zsh way to do it
- if [[ "$_sp_source_file" == *":A" ]]; then
+ _sp_source_file="${(%):-%N}" # zsh way to do it
+ if [ -z "$_sp_source_file" ]; then
# Not zsh either... bail out with plain old $0,
# which WILL NOT work if this is sourced indirectly.
_sp_source_file="$0"