Added ZSH support for micromamba - #262
Conversation
There was a problem hiding this comment.
Hello, welcome to the project!
There are multiple bash script files using this or similar methods for obtaining the location of the script (e.g., .ci/micromamba/run_test.sh, .ci/micromamba/uninstall.sh); those should be updated too.
If possible, I suggest avoiding the ZSH-specific execution path and using something that works universally. (The solution I used in run_test.sh seems to work in ZSH too, please check that! -- does not work with sourcing)
I'm slightly concerned about the impact of ZSH support inside basel.
Since we are not explicitly supporting ZSH, I relabeled this as an enhancement, not a bug.
| @@ -1,2 +1,2 @@ | |||
| # Make sure we source the script | |||
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | |||
There was a problem hiding this comment.
This line does not work in ZSH; see the following example script:
furtib@emypc ~ % cat test.sh
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "ERROR: This script must be 'sourced':"
echo " source ${0}"
exit 1
fi
furtib@mypc ~ % ./test.sh
./test.sh: 1: Bad substitutionThere was a problem hiding this comment.
Added shebang, so the script always runs in bash when not sourced.
Unfortunately, I could not find a universal way of getting the correct path. If the support of ZSH is a concern, then perhaps it would be better to simply check if the script is sourced from bash and exit with an instruction if it is not.
I will update the other scripts with whichever solution is preferred.
If the script is not sourced then run the check in bash.
Why:
When using Zsh source
source .ci/micromamba/init.shdid not work, because it did not find the location of the script.What:
Added a branch if the shell is Zsh
Addresses:
None