Restore POSIX compatibility in micromamba profile script#4117
Open
ndevenish wants to merge 2 commits intomamba-org:mainfrom
Open
Restore POSIX compatibility in micromamba profile script#4117ndevenish wants to merge 2 commits intomamba-org:mainfrom
ndevenish wants to merge 2 commits intomamba-org:mainfrom
Conversation
-v in test seems to explicitly be _not_ POSIX compliant, and requires bash v4+. This is a problem on macOS, where the system version of bash is <4 and usually the default shell is zsh now. This test works in zsh, so only causes a problem when trying to source-activate the environment from a script running inside /bin/bash. This restores the POSIX compatible test, but also protects against opt -u by defaulting to empty if the variable is not present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This
micromamba/etc/profile.d/mamba.sh.inwas updated in the commit 0d3758d, with the original commit message being "Use a POSIX-compliant check".However,
test -vseems to explicitly be not POSIX compliant, and requires bash v4+. This can be a problem on macOS, where the system version of bash is permanently <4 (because Apple and GPL). This test works in zsh, the usual default on macOS now, so only causes a problem when trying to source-activate the environment from a script running inside /bin/bash. (line 1: [: -v: unary operator expected).This restores the POSIX compatible test, but also protects against opt -u (possibly another intent of the original change?) by defaulting to empty if the variable is not present. This test does also look to be POSIX compliant.
Type of Change
Checklist
pre-commit run --alllocally in the source folder and confirmed that there are no linter errors.