Repository navigation
fix(marketplace-check): leading-paren case pattern inside $( ) for bash 3.2; portability rule (#763) - #774
fix(marketplace-check): leading-paren case pattern inside $( ) for bash 3.2; portability rule (#763)#774MendixMau wants to merge 1 commit into
Conversation
…sh 3.2; portability rule (#763) _mkt_locate ran `case "$m" in *"refusing to guess"*)` inside a command substitution; macOS /bin/bash 3.2 reads the pattern's `)` as the end of the $( ), so every exec of a domain-model script stopped at the marketplace check. Use the POSIX `(pat)` form. Sweep of bin/, bin/lib/, project-bin/ and claude-hooks/ found no other occurrence. check-portability.sh rule 3 (bin/lib/case-in-subst.awk, multi-line scan) flags a case pattern without a leading `(` inside $( ). Master tree: 1 hit (marketplace-check.sh:115); branch: clean over 391 files. Fixture tests/wave2/test-case-in-subst.sh: master 2/4, branch 4/4. Reported by thanarat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
|
Review: MERGE. The one-character fix at Value: Fixes #763 as reported.
Regression risk:
Correctness: All fixtures were run in the detached worktree.
Extra edge cases run against the awk all behaved correctly, with only the two real bare patterns flagged:
The documented blind spots (backticks, Context cost: 66196 → 66196 always-loaded words (measured). No routed file touched. Time cost: per Generated by Claude Code |
Fixes #763
Direct lane
What changed and why (one paragraph):
_mkt_locateinbin/lib/marketplace-check.sh:115rancase "$m" in *"refusing to guess"*) ... esacinside a$( ... )command substitution. macOS/bin/bash3.2 reads the pattern's unmatched)as the end of the substitution. Per the report, everybin/exec.shrun on a domain-model script stopped at the marketplace check.bash -ncannot catch this, because 3.2 parses the substitution only when it runs. It is the same class of bug as #552. The pattern now uses the POSIX leading paren:(*"refusing to guess"*).To stop a third one from landing,
bin/check-portability.shgets rule 3. The rule runsbin/lib/case-in-subst.awk, a whole-file, multi-line scan:$( ),( ),"...",${ },$(( ))/(( ))andcase(subject, then pattern, then body).'...'strings (also across lines), comments and heredoc bodies.)that has no leading(while a$( )sits anywhere below thecase.# portability-ok:opt-out works per line.A one-line pointer to the new rule was added to
bin/check-scripts.sh's header, which already named this gap.Sweep: I ran the scanner over
bin/,bin/lib/,project-bin/,claude-hooks/andtests/. It found one occurrence,bin/lib/marketplace-check.sh:115, the one reported. There were no others to fix. As a sanity check on the scanner, all 390 files on master end with an empty context stack: no unclosed quote, heredoc or substitution, so the state did not drift.Proof, and its limit: bash 3.2 is not available on this runner, so I did not reproduce the runtime failure here. The proof is static: the portability-check fixture. The reporter verified the
(pat)fix on bash 3.2 and bash 5.check-portability.shtests/wave2/test-case-in-subst.shbin/check-portability.shover the toolkit treebin/lib/marketplace-check.sh:115Fixture cases:
(pat)one), and a nested$( … $(case …) … ). All 3 flagged at the right lines.(pat)inside$( ), a case outside any$( )with$( )in its subject and body, a commented line, a'...'string, a quoted heredoc body,$(( … << … ))and a# portability-ok:line. 0 hits.marketplace-check.shgives 0 hits. This passes trivially on master, because master has no such rule.Known false negatives, documented in the awk header: backtick substitutions and
<( )are not tracked as substitutions, and${…}bodies are opaque.Impact
check-portability.sh(CI step andtests/run-tests.sh) can now fail on a new violation class. It reports 0 on the current tree.bin/check-portability.sh,bin/check-scripts.sh(comment only) andbin/lib/marketplace-check.sh(one pattern). Newbin/lib/case-in-subst.awkuses POSIX awk only:match/RLENGTH,substr,index,sub/gsub. It was written for gawk, mawk and BSD awk alike, but I exercised it only on this runner's awk.check-portability.shis not installed into projects, so no sync impact. No new artifact reads.check-portability.shrun takes several minutes here anyway.marketplace-check.sh: unchanged wall-clock, and the hard failure on bash 3.2 is gone.Time cost: per check-portability run · ~2.2 s measured on Linux CI-class runner · can force rework: y (a new bare pattern in
$( )fails CI) · offset: removes a hard stop on every domain-model exec on stock macOS bashField evidence: reported by thanarat on macOS
/bin/bash3.2.57, mxcli v0.31.0, toolkit v2026.11.16: everybin/exec.shon a domain-model script stopped at the check. The reporter verified the(pat)fix there on bash 3.2 and bash 5. The new rule ran against this toolkit's real tree: 1 hit on master, 0 on the branch.bin/check-scripts.sh(137/137 parse). No bash 3.2 runtime run on this runner.CHANGELOG.mdline under## Unreleased, credited to thanaratNot run:
tests/wave2/test-marketplace-install.shandtest-fitgap-review.sh, which loadmarketplace-check.sh, plus the other fixtures that callcheck-portability.sh(test-sed-tab-bracket.sh,test-status-bare-var.sh,test-pipefail-grep-q.sh). This session's permission check refused the run. The reviewer may run them in a detached worktree.Review: pending independent review
Generated by Claude Code