Skip to content

fix: add set -o pipefail and fix SIGPIPE in all bin scripts#152

Open
0xheartcode wants to merge 1 commit intoremenoscodes:mainfrom
0xheartcode:fix/pipefail-sigpipe
Open

fix: add set -o pipefail and fix SIGPIPE in all bin scripts#152
0xheartcode wants to merge 1 commit intoremenoscodes:mainfrom
0xheartcode:fix/pipefail-sigpipe

Conversation

@0xheartcode
Copy link

Switch shebang from #!/bin/sh to #!/bin/bash and add set -o pipefail after set -e in all 20 executable bin scripts. Fixes the three failing Quality Gates jobs.

Why

set -o pipefail is not POSIX — on Linux, /bin/sh is dash which 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

  • Shebang: #!/bin/sh#!/bin/bash in all 20 scripts
  • pipefail: set -o pipefail added after set -e in all 20 scripts
  • SIGPIPE fixes to prevent exit 141 under pipefail:
    • git log ... | sed '/^$/d' | head -1git log -1 ... | sed '/^$/d' (drop redundant head -1, use -1 flag)
    • printf '$var' | head -1 → shell parameter expansion ${var%%$'\n'*}
    • Remaining truncating pipes wrapped in (set +o pipefail; ...)

No logic changes — only error propagation and pipe handling corrected.

Test plan

  • sh t/test-issue.sh: 76 passed, 0 failed
  • sh t/test-failure-modes.sh: 19 passed, 0 failed, 1 skipped
  • Static Analysis (act): ✅ All scripts have set -o pipefail

Closes #127

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
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.

Add set -o pipefail to all bin scripts

1 participant