test/selftest/070-and-comm-s-two-inputs-must.sh requires every | sort in a file that uses comm to carry LC_ALL=C. Its pattern is a pipe:
grep -E '\|[[:space:]]*sort' "$_f"
A process-substituted sort — comm -23 <(sort "$1") <(sort "$2") — is not a pipeline, so the guard never sees it.
Measured on test/run_all_versions.sh
matches for '| sort' : 0
occurrences of '<(sort ...)': 3
selftest 070 verdict : run_all_versions.sh passes the guard
A file that uses comm three times reads as compliant because it never pipes into sort. The three:
pgc_own_mechanism_suites() { comm -13 <(sort "$1") <(sort "$2"); }
pgc_ran_without_accounting() { comm -23 <(sort "$1") <(sort "$2"); } # added by #1110
pgc_accounted_among() { comm -12 <(sort "$1") <(sort "$2"); } # added by #1110
The same file already applies the convention correctly 500 lines away, which is what makes the gap worth closing rather than arguing about:
LC_ALL=C sort -u "$_reg" >"$_rf"
LC_ALL=C comm -23 "$_rf" "$_af" >"$_t1"
The inputs are not collation-insensitive
Ten real suite names, two collations:
LC_ALL=C ... pg_dump_roundtrip pgc_setup ... projection_update projections
LC_ALL=en_US ... pgc_setup pg_dump_roundtrip ... projections projection_update
Two pairs swap, and comm says so when fed en_US-sorted input:
comm: file 1 is not in sorted order
comm: input is not in sorted order
Severity: latent on every environment the gate runs in
Checked rather than assumed. The workflows set no locale, the audit container is C.UTF-8, and C.UTF-8 orders these identically to C. It bites a developer whose box is en_US.UTF-8, which is a common default.
The guard's own comment already notices the distinction it does not cover:
The first reads a FILE and is not a pipeline at all.
What would fix it
Widen the pattern to reach <(sort, $(sort and a bare sort FILE fed to comm, rather than only | sort. The false-positive budget should be measured over the tree first — sort appears in plenty of files that never touch comm, and the guard is already correctly scoped to files that do.
Worth a removal proof in both directions: a <(sort without LC_ALL=C must redden, and the existing piped-sort case must keep reddening.
Provenance
Found while reviewing #1110, whose two new helpers join a pre-existing one. Not a defect #1110 introduced — raised there and approved, with the fix left to whoever takes this.
The other half of the same guard works: adding a comm to docs_style.sh in #1108 correctly flagged five pre-existing piped sorts, which is how I came to look at the pattern at all.
test/selftest/070-and-comm-s-two-inputs-must.shrequires every| sortin a file that usescommto carryLC_ALL=C. Its pattern is a pipe:A process-substituted sort —
comm -23 <(sort "$1") <(sort "$2")— is not a pipeline, so the guard never sees it.Measured on
test/run_all_versions.shA file that uses
commthree times reads as compliant because it never pipes intosort. The three:The same file already applies the convention correctly 500 lines away, which is what makes the gap worth closing rather than arguing about:
The inputs are not collation-insensitive
Ten real suite names, two collations:
Two pairs swap, and
commsays so when fed en_US-sorted input:Severity: latent on every environment the gate runs in
Checked rather than assumed. The workflows set no locale, the audit container is
C.UTF-8, andC.UTF-8orders these identically toC. It bites a developer whose box isen_US.UTF-8, which is a common default.The guard's own comment already notices the distinction it does not cover:
What would fix it
Widen the pattern to reach
<(sort,$(sortand a baresort FILEfed tocomm, rather than only| sort. The false-positive budget should be measured over the tree first —sortappears in plenty of files that never touchcomm, and the guard is already correctly scoped to files that do.Worth a removal proof in both directions: a
<(sortwithoutLC_ALL=Cmust redden, and the existing piped-sort case must keep reddening.Provenance
Found while reviewing #1110, whose two new helpers join a pre-existing one. Not a defect #1110 introduced — raised there and approved, with the fix left to whoever takes this.
The other half of the same guard works: adding a
commtodocs_style.shin #1108 correctly flagged five pre-existing piped sorts, which is how I came to look at the pattern at all.