dotnet / install-scripts

MIT License
140 stars 75 forks source link

dotnet-install.sh fails when dot-sourced from the command line #519

Open JayBazuzi opened 3 months ago

JayBazuzi commented 3 months ago

On a Mac running ZSH:

> . dotnet-install.sh   
(eval):1: FUNCNAME[0]: parameter not set
(eval):1: FUNCNAME[0]: parameter not set

and then my shell closes, ouch!

MichalPavlik commented 1 month ago

I can repro using zsh 5.8 (x86_64-ubuntu-linux-gnu)

MichalPavlik commented 1 month ago

I think I know the reason. The script instructs shell to exit if an unset variable is encountered (via set -u). The FUNCNAME[0] located here: https://github.com/dotnet/install-scripts/blob/033622cafb10f813db17a4ed511f2bbade9a77ee/src/dotnet-install.sh#L15

is a Bash specific thing. ZSH uses funcstack, but I'm not sure why it fails only when dot-sourced.