Repository navigation
Description
What is missing
No CI gate checks shell scripts for GNU-only constructs. This is a missing capability, not a defect in an existing gate.
To be explicit about what already exists and why neither covers this:
portability-lint/ ci: portability lint lane — enforce declared agnosticism mechanically (19-issue coupling class + top review-churn source) #531 matches skill-coupling tokens (stack, forge, branch, tracker defaults) fromscripts/skill-portability-tokens.txtagainst changed skill files. That is its job and it does it. It is not a shell-portability gate and was never meant to be.- ci: no Windows runner anywhere — green checks carry no signal for platform-sensitive shell changes #1414 ("no Windows runner anywhere") is adjacent but different. A Windows runner would not catch this class either: Git Bash on Windows ships GNU grep, so a GNU-only construct passes there exactly as it passes on
ubuntu-24.04. The exposure is BSD userland — macOS systemgrep/sed— which no runner in this repo covers.
The concrete near-miss that motivated this
While hardening plugins/markdown-format/hooks/markdown-format.sh on #1097, a predicate deciding whether a markdownlint config's module specifiers can be pinned to an approval was written with \b word boundaries:
grep -Eq '\brequire\b' "$file"\b is a GNU extension. POSIX leaves \<ordinary char> undefined, and BSD grep may read \b as a literal b — turning \brequire\b into brequireb, which matches nothing. The predicate would then have returned "nothing unpinnable found" for every input.
That is a fail-open in a security predicate, on macOS, that no test on a GNU runner could ever catch. markdown-format.sh's own header explicitly commits to macOS system bash, so the platform is in declared scope.
The fix, now on main, is POSIX-portable and is the reference implementation for what a gate should accept:
- word starts/ends spelled as bracket expressions —
(^|[^A-Za-z0-9_$])require($|[^A-Za-z0-9_$])— instead of\b - the residue test uses
grep -qrather thangrep -o, so no boundary character is consumed (which is what made a count-based approach undercount a nestedrequire(require("x")))
Suggested shape
A changed-file-scoped lane over **/*.sh flagging GNU-only constructs. Non-exhaustive starter set, all of which differ or are undefined under BSD userland:
- ERE/BRE:
\b,\<,\>,\s,\S,\w,\W,\+,\?ingrep/sedpatterns grep -P(PCRE — absent in BSD grep and in some GNU builds)sed -iwithout a backup suffix (BSD requires an argument)sed\|,\+,\?and GNU-only addressesreadlink -f,date -d,stat -c,mktemp -p,head -con some builds,sort -Vecho -e
Two design notes from the near-miss:
- The token list belongs outside the script, the way ci: portability lint lane — enforce declared agnosticism mechanically (19-issue coupling class + top review-churn source) #531's does, so a re-catch is a one-line data change rather than a gate edit.
- Direction matters. Flagging a GNU-ism that is actually safe costs a reviewer one line of justification; missing one in a security predicate costs a silent fail-open. The gate should over-flag and allow an inline opt-out with a stated reason, not under-flag.
An alternative or complement worth weighing: run the existing shell test suites once under a BSD-userland container so the behavioral difference surfaces as a test failure rather than a lint finding. That catches constructs no token list anticipated, at the cost of a slower lane.
Provenance
Found on #1097 by adversarially re-probing a predicate I had just written, not by any reviewer. It is the kind of defect that produces no symptom until it is exploited on the one platform CI does not cover.
Activity
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Triage
Verification: CONFIRMED as a missing capability, not a currently-shipped defect.
The specific near-miss (a
grep -Eq '\brequire\b'GNU-only\bword boundary inplugins/markdown-format/hooks/markdown-format.sh) is already fixed onmain— I grepped thecurrent file for
\b-style boundary patterns and found none; the live predicate uses thebracket-expression form the issue describes as the reference implementation
(
(^|[^A-Za-z0-9_$])(require($|[^A-Za-z0-9_$])|import[[:space:]]*\(), confirmed atunpinnable_js_specifier()). So there is no live fail-open defect today.The gap claim itself also checks out:
.github/workflows/ci.ymlrunsshellcheck(twice) and aportability-lintjob, but I confirmedportability-lint(scripts/check-skill-portability.sh)matches only the skill-coupling token list in
scripts/skill-portability-tokens.txtagainst changedskill files — it has no GNU-vs-BSD regex-construct vocabulary, and ShellCheck's own scope is shell
syntax/style, not portability of patterns handed to
grep/sedas string arguments. Neither toolwould have caught the original
\bconstruct. No other gate in the workflow targets shellportability. Confirmed: this is a real, currently-missing CI capability.
Classification
fixed, so there is no live exposure, but the failure mode (a fail-open security predicate on an
uncovered platform) is high-severity when it recurs and no gate exists to catch a repeat.
work-class: scoped— a new changed-file-scoped lint lane over**/*.sh, followingthe existing
portability-lintjob's external-token-list pattern.agent-ready), decision-defaulted.Decision defaulted: implement the token-list-based lint lane (mirroring
#531'sportability-lintshape: token list lives in an external data file, gate over changed**/*.shfiles, over-flag with an inline opt-out) rather than the BSD-userland-container test-run
alternative — veto before merge if you'd rather run the shell suites under a BSD container
instead (or in addition). The token-list approach is cheaper, matches an established precedent in
this repo, and the issue's own "Two design notes" section (token list outside the script; over-flag
rather than under-flag) already specify its shape completely — the only open question is the
starter token list's exact membership, which is a reversible, low-stakes choice the implementer can
make from the issue's own "non-exhaustive starter set." The container-based alternative remains a
valid complement a maintainer can request afterward; it is not blocked by this default.
Agent Brief
Type: Task
Summary: Add a CI gate that flags GNU-only shell constructs in changed
**/*.shfiles, so aBSD-userland-incompatible construct (macOS system
grep/sed) is caught before merge instead offailing silently on the one platform no CI runner here covers.
Current behavior: No gate in this repository's CI checks shell scripts for GNU-only regex/flag
constructs.
shellcheckandportability-lint(skill-coupling tokens) both run today but neithercovers this class, and no runner in the workflow uses BSD userland (a Windows runner's Git Bash still
ships GNU grep/sed, so it would not help either).
Desired behavior: A changed-file-scoped CI lane over
**/*.shthat flags GNU-only constructs(word-boundary regex escapes,
grep -P,sed -iwithout a backup-suffix argument, GNU-onlysedaddresses,
readlink -f,date -d,stat -c,mktemp -p,sort -V,echo -e, and similar), withan external token/pattern list (not hardcoded in the gate script) and an inline opt-out mechanism for
a reviewed false positive. Direction over-flags rather than under-flags: a justified false positive
costs a reviewer one line; a missed true positive can ship a silent fail-open security predicate.
Key interfaces: a new gate script (data-driven from an external pattern/token list file, same
shape as
scripts/skill-portability-tokens.txtforportability-lint), wired as a new CI job scopedto changed
.shfiles.Acceptance criteria:
grep/sedpatterns,
grep -P, unsuffixedsed -i, GNU-onlydate/stat/readlink/mktemp/sortflag forms,
echo -e) in changed shell files.plugins/markdown-format/hooks/markdown-format.sh'sunpinnable_js_specifier()(a known-goodconstruct to self-test against).
Out of scope: running the existing shell test suites under an actual BSD-userland container (a
valid complementary approach the issue names as "worth weighing," left for a separate decision);
rewriting any currently-shipped shell script.
kyle-sexton commentedon Jul 26, 2026
fix(ci): correct two shell-portability-lint false results (#1519)
fix(ci): harden shell-portability-lint detection precision (#1534)
fix(ci): detect sort's --version-sort / --sort=version long forms (#1530
ci: enable staged shell-portability-lint classes (date -d, stat -c)
ci: enable staged shell-portability-lint classes (date -d, stat -c)
ci: migrate mktemp -p test-scaffolding call sites to a portable form (#…
fix(ci): shell-portability-lint's sort -V token misses operator-termi…
ci: enable staged shell-portability-lint classes (date -d, stat -c) (#…
ci(scripts): flag a bare & in a ${var//pat/repl} replacement (#2097)