summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
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"