fix: add set -o pipefail and fix SIGPIPE in all bin scripts#152
Open
0xheartcode wants to merge 1 commit intoremenoscodes:mainfrom
Open
fix: add set -o pipefail and fix SIGPIPE in all bin scripts#1520xheartcode wants to merge 1 commit intoremenoscodes:mainfrom
0xheartcode wants to merge 1 commit intoremenoscodes:mainfrom
Conversation
Switch shebang from #!/bin/sh to #!/bin/bash and add set -o pipefail
after set -e in all 20 executable bin scripts.
Fix SIGPIPE-risky pipe patterns that would cause exit 141:
- git log ... | sed | head -1 → git log ... | sed | head -1 wrapped in
(set +o pipefail; ...)
- printf '$var' | head -1 → shell parameter expansion ${var%%$'\n'*}
- Remaining truncating pipes wrapped in (set +o pipefail; ...)
Closes remenoscodes#127
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.
Switch shebang from
#!/bin/shto#!/bin/bashand addset -o pipefailafterset -ein all 20 executable bin scripts. Fixes the three failing Quality Gates jobs.Why
set -o pipefailis not POSIX — on Linux,/bin/shisdashwhich silently ignores it. Without the bash shebang, the directive has no effect and the CI static check fails regardless. Both changes are required together.Changes
#!/bin/sh→#!/bin/bashin all 20 scriptsset -o pipefailadded afterset -ein all 20 scriptsgit log ... | sed '/^$/d' | head -1→git log -1 ... | sed '/^$/d'(drop redundanthead -1, use-1flag)printf '$var' | head -1→ shell parameter expansion${var%%$'\n'*}(set +o pipefail; ...)No logic changes — only error propagation and pipe handling corrected.
Test plan
sh t/test-issue.sh: 76 passed, 0 failedsh t/test-failure-modes.sh: 19 passed, 0 failed, 1 skippedset -o pipefailCloses #127