Skip to content

Require bash 4+ explicitly instead of failing silently under /bin/bash - #3

Open
systemjack wants to merge 1 commit into
gherlein:mainfrom
systemjack:fix-bash4-requirement
Open

Require bash 4+ explicitly instead of failing silently under /bin/bash#3
systemjack wants to merge 1 commit into
gherlein:mainfrom
systemjack:fix-bash4-requirement

Conversation

@systemjack

Copy link
Copy Markdown

localdev-mounts.sh uses declare -A for mount-target collision detection, so it
needs bash 4.0+. Every launcher declared #!/bin/bash, which on macOS is bash
3.2.57 -- the one interpreter that cannot run it.

The failure was silent and wrong rather than loud. Under 3.2 declare -A fails,
USED_TARGETS degrades to an indexed array, subscript expansion is evaluated as
arithmetic, and .localdev-mounts.toml entries are dropped with no error. The
container then comes up missing mounts the user believes are present -- observed
as a workspace whose read-only reference repo simply was not there, with nothing
in the output to say so beyond two stray declare: -A: invalid option lines.

The same breakage silently disabled the collision guard itself, so two host
directories claiming one container target went undetected on macOS for as long
as the file-mount feature has existed.

Two changes:

  • Shebangs become #!/usr/bin/env bash in all four launchers and the library, so
    a PATH-resolved bash 4+ (Homebrew's, typically) is preferred over /bin/bash.
  • The library asserts BASH_VERSINFO >= 4 and exits with an actionable message
    naming the running version and interpreter. #!/usr/bin/env bash alone would
    still fail silently for anyone without a modern bash on PATH, and silently
    dropping mounts is not an acceptable failure mode.

Verified: launched by name, the .localdev-mounts.toml entry is now present in the
podman args as :ro; invoked as /bin/bash localdev it aborts with the version
error rather than proceeding; and the collision guard now correctly aborts on two
mounts sharing a target, which it never did on macOS before.

This affects every macOS host, since /bin/bash there is 3.2 -- anyone relying on
.localdev-mounts.toml has been silently losing mounts.

Also documents the requirement in README Prerequisites. The runtime guard tells
you after the fact; a macOS user needs to know before their first launch that
brew install bash is a setup step, not an optional nicety.

localdev-mounts.sh uses `declare -A` for mount-target collision detection, so it
needs bash 4.0+. Every launcher declared `#!/bin/bash`, which on macOS is bash
3.2.57 -- the one interpreter that cannot run it.

The failure was silent and wrong rather than loud. Under 3.2 `declare -A` fails,
USED_TARGETS degrades to an indexed array, subscript expansion is evaluated as
arithmetic, and .localdev-mounts.toml entries are dropped with no error. The
container then comes up missing mounts the user believes are present -- observed
as a workspace whose read-only reference repo simply was not there, with nothing
in the output to say so beyond two stray `declare: -A: invalid option` lines.

The same breakage silently disabled the collision guard itself, so two host
directories claiming one container target went undetected on macOS for as long
as the file-mount feature has existed.

Two changes:

- Shebangs become `#!/usr/bin/env bash` in all four launchers and the library, so
  a PATH-resolved bash 4+ (Homebrew's, typically) is preferred over /bin/bash.
- The library asserts BASH_VERSINFO >= 4 and exits with an actionable message
  naming the running version and interpreter. `#!/usr/bin/env bash` alone would
  still fail silently for anyone without a modern bash on PATH, and silently
  dropping mounts is not an acceptable failure mode.

Verified: launched by name, the .localdev-mounts.toml entry is now present in the
podman args as :ro; invoked as `/bin/bash localdev` it aborts with the version
error rather than proceeding; and the collision guard now correctly aborts on two
mounts sharing a target, which it never did on macOS before.

This affects every macOS host, since /bin/bash there is 3.2 -- anyone relying on
.localdev-mounts.toml has been silently losing mounts.

Also documents the requirement in README Prerequisites. The runtime guard tells
you after the fact; a macOS user needs to know before their first launch that
`brew install bash` is a setup step, not an optional nicety.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant