fix(ci): use portable fallbacks for bash-4 builtins and GNU sed in hook scripts#3694
fix(ci): use portable fallbacks for bash-4 builtins and GNU sed in hook scripts#3694jiengup wants to merge 1 commit into
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
hubcio
left a comment
There was a problem hiding this comment.
the -i.bak switch itself is the right call and matches the trailing-whitespace.sh precedent. main ask is the && rm -f chaining - it quietly replaces the old loud sed failure with a false "Fixed" + exit 0 (details in the line comments).
two findings sit on lines outside this diff, so noting them here:
scripts/verify-crates-publish.sh:313-lc="${crate,,}"is bash-4-only, stock macOS bash 3.2 dies withbad substitution, and it fails late (after all four crates already published to the local registry). it's also a no-op since the crate names are already lowercase, solc="$crate"fixes it for free.scripts/ci/python-sdk-version-sync.sh:144-sort -Vis GNU coreutils-only, BSD sort rejects it. the--fixpath hits it exactly when the two versions differ, i.e. the case the hook exists for. worth confirming on an actual mac.
with a\, \b and these two still around, #3693 ends up only partially closed for macos contributors - either keep the issue open or note a follow-up in the PR.
| -e 's|^(iggy = \{ path = "[^"]+", version = "[^"]+")( \})$|\1, registry = "local-dev"\2|' \ | ||
| -e 's|^(iggy-cli = \{ path = "[^"]+", version = "[^"]+")( \})$|\1, registry = "local-dev"\2|' \ | ||
| Cargo.toml | ||
| Cargo.toml && rm -f Cargo.toml.bak |
There was a problem hiding this comment.
-i.bak now creates Cargo.toml.bak, but cleanup() only restores Cargo.toml from the mktemp snapshot - it never removes the .bak. if sed fails (the && skips the rm and the sanity check below exits 1) or a ctrl-c lands between sed and rm, Cargo.toml.bak survives the trap, which breaks the "leave the working tree untouched on exit, even on failure" contract at the top of this file. *.bak isn't gitignored either. one rm -f Cargo.toml.bak inside the CARGO_TOML_PATCHED branch of cleanup() covers all paths. the && itself is fine here - the sanity check right below fails closed.
Closes #3693
Rationale
Several hook scripts use
mapfile(bash >= 4) andsed -iwithout backup extension (GNU extension). On macOS stock bash 3.2 and BSD sed, these fail, blocking contributors from committing.What changed
mapfilecalls now guard withcommand -v mapfileand fall back to awhile IFS= read -rloop.sed -icalls is replaced by thesed -i.bak && rmpattern already established intrailing-whitespace.sh.Local Execution
prek run -a