Repository navigation
fix(dev): self-relaunch dev.sh under bash if invoked via sh/dash - #86
Merged
Merged
Conversation
When a user types `sh scripts/dev.sh` (or runs it under dash, or under any
non-bash POSIX shell), they'd hit:
dev.sh: line 48: syntax error: bad substitution
dev.sh: line 104: syntax error: unexpected "(" (expecting "fi")
…because dev.sh uses bash-only features (${BASH_SOURCE[0]}, array assignment,
wait -n). The shebang only takes effect for `./dev.sh` invocations; an
explicit `sh dev.sh` ignores it.
Fix: add a POSIX-compatible guard at the top that re-execs under bash if
${BASH_VERSION} isn't set, with a friendly error if bash isn't installed at
all. The guard itself uses only POSIX-clean syntax so sh can parse it.
Also bump the --help sed range to match the new line numbers.
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.
Summary
Reported by a user invoking the script with
sh scripts/dev.sh:The script's shebang (
#!/usr/bin/env bash) only kicks in when you run./dev.sh. An explicitsh dev.shoverrides it and hits dash/sh, which can't parse${BASH_SOURCE[0]}(line 48) orCOMPOSE_ARGS=(-f ...)(line 104).Fix: prepend a POSIX-clean guard that re-execs under bash if
$BASH_VERSIONis unset, with a friendly error if bash isn't installed. Verified by runningsh scripts/dev.sh --helpand getting the proper help text.Also bumped the
--helpsed range to match the new line numbers.Test plan
sh scripts/dev.sh --help→ re-execs and prints help (previously failed at line 48)bash scripts/dev.sh --helpstill works unchangedpnpm format:checkclean