Closed JayBazuzi closed 1 month ago
@mairaw do you know who owns this now?
Adding @MichalPavlik and @YuliiaKovalova
@baronfel, I think the problem is caused by this line: https://github.com/dotnet/install-scripts/blob/c4501ac2f3714e080e425ce499a0f077ab15a0b0/src/dotnet-install.sh#L1738
Is this behavior expected?
It's not bad in the sense that it's not harming anything, but generally you wouldn't dot source this script. Is not that kind of script. We can change this to hard-code the name but it's kind of a mixed bag, because then you're incorrect if the users just rename the script.
generally you wouldn't dot source this script
Right here it says it is intended to be dot-sourced: https://github.com/dotnet/install-scripts/blob/c4501ac2f3714e080e425ce499a0f077ab15a0b0/src/dotnet-install.sh#L1860
One option is to stop supporting dot-sourcing all together.
An approach I have used elsewhere is to add an option to suppress all other stdout and only print the path. Then the caller can do:
export PATH="$( ./dotnet-install.sh --print-path-only )":"$PATH"
There is no portable way to get the name of a script that is sourced - you have to do bash- or zsh- or other-shell-specific code to get that. I'm not convinced that this is a high priority to be 100% correct in all scenarios. We should either ignore this side effect or hard-code the dotnet-install.sh
name.
There is no portable way to get the name of a script that is sourced - you have to do bash- or zsh- or other-shell-specific code to get that. I'm not convinced that this is a high priority to be 100% correct in all scenarios. We should either ignore this side effect or hard-code the
dotnet-install.sh
name.
I would vote for hardcoding the name. I don't envision a change of it .
Hardcoding was my first thought. I don't think we will change the name, and I don't see a reason why would customers change the script name...
I don't see a reason why would customers change the script name
Because the instructions are basically "download a file and run it", they might download it to any name of their choosing. If they download in a browser, the browser will add a (1)
or similar if there's a conflict. If they copy it in Explorer, it will get Copy of
.
That said, I think hard-coding the name and being wrong in these cases is reasonable.
I didn't think too much about browsers and Explorer as this script is designed to be used in CI. Anyway, we will hardcode the name :)
Make a script
my-script.sh
:When run it prints out:
Note that the help says
my-script.sh
instead ofdotnet-install.sh
.