Skip to content

Problem #1219

Description

@hyperpolymath

Problem

.githooks/validate-k9.sh decides whether a nonconforming K9 file blocks a
commit with:

if [ -n "$CHANGED" ] && printf '%s\n' "$CHANGED" | grep -qxF "$file"; then

Under set -o pipefail, grep -q exits as soon as it matches and closes the
pipe. printf then receives SIGPIPE. On large change lists this produces false
negatives — a file that WAS touched is reported as untouched, so a change to a
nonconforming file slips through as advisory instead of blocking.

Measured at roughly 12–14% of runs on large change lists.

Fix

Use a here-string so there is no pipe and no SIGPIPE:

if [ -n "$CHANGED" ] && grep -qxF -- "$file" <<< "$CHANGED"; then

Acceptance

  • A regression test that fails on the current form and passes on the fixed
    form: a large $CHANGED list where the file is present, asserted to be
    detected.
  • The test lives under scripts/tests/ so scripts/run-shell-test-suite.sh
    picks it up.
  • Fix and test land together.

Notes

Deliberately NOT bundled with the 9-archive district move (#1218), which only
added an is_fixture() case to this script.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions