Skip to content

Added ZSH support for micromamba - #262

Open
Makkareal wants to merge 2 commits into
Ericsson:mainfrom
Makkareal:micromamba_zsh_fix
Open

Added ZSH support for micromamba#262
Makkareal wants to merge 2 commits into
Ericsson:mainfrom
Makkareal:micromamba_zsh_fix

Conversation

@Makkareal

Copy link
Copy Markdown

Why:
When using Zsh source source .ci/micromamba/init.sh did not work, because it did not find the location of the script.

What:
Added a branch if the shell is Zsh

Addresses:
None

@Szelethus
Szelethus requested review from Szelethus and furtib July 8, 2026 12:04
@Szelethus Szelethus added the bug Something isn't working label Jul 8, 2026

@furtib furtib left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .ci/micromamba/init.sh
@@ -1,2 +1,2 @@
# Make sure we source the script
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then

@furtib furtib Jul 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 substitution

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@furtib furtib added enhancement New feature or request and removed bug Something isn't working labels Jul 11, 2026
If the script is not sourced then run the check in bash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants