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).
This commit is contained in:
parent
9a79a2345d
commit
88cc895a70
@ -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="${(%):-%N}" # zsh way to do it
|
||||
if [ -z "$_sp_source_file" ]; then
|
||||
_sp_source_file="$0:A" # zsh way to do it
|
||||
if [[ "$_sp_source_file" == *":A" ]]; then
|
||||
# Not zsh either... bail out with plain old $0,
|
||||
# which WILL NOT work if this is sourced indirectly.
|
||||
_sp_source_file="$0"
|
||||
|
Loading…
Reference in New Issue
Block a user