Repository navigation
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.
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.
There was a problem hiding this comment.
That sounds like a great alternative solution. Lets pursue that.
Szelethus
left a comment
There was a problem hiding this comment.
In hindsight, I also think it'd be wiser to only support bash.
There was a problem hiding this comment.
That sounds like a great alternative solution. Lets pursue that.
e9222c1 to
438aacc
Compare
Check whether BASH_SOURCE[0] is empty, and emit an error asking to source from bash when it is.
Szelethus
left a comment
There was a problem hiding this comment.
You need to fix the lint CI job, otherwise LGTM
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 check to see if the source file and thus its location could be found, otherwise asks the user to source from bash.
Addresses:
None