Skip to content

Restore POSIX compatibility in micromamba profile script#4117

Open
ndevenish wants to merge 2 commits intomamba-org:mainfrom
ndevenish:fix_mamba_sh
Open

Restore POSIX compatibility in micromamba profile script#4117
ndevenish wants to merge 2 commits intomamba-org:mainfrom
ndevenish:fix_mamba_sh

Conversation

@ndevenish
Copy link

Description

This micromamba/etc/profile.d/mamba.sh.in was updated in the commit 0d3758d, with the original commit message being "Use a POSIX-compliant check".

However, test -v seems 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

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

-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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::bug_fixes For PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant