From 88cc895a7067dc6b7662755796a7cd749f71aee2 Mon Sep 17 00:00:00 2001 From: paulanda <40282207+paulanda@users.noreply.github.com> Date: Tue, 16 Apr 2019 13:33:02 -0600 Subject: 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). --- share/spack/setup-env.sh | 6 +++--- 1 file 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" -- cgit v1.2.3-60-g2f50