Repository navigation
fix(#282) [P1-high]: eval EOF-shape probe is comment-aware - restores the modernish fatal.sh battery receipt (166-probe ledger) - #572
Conversation
…omments no longer fabricate unclosed comsub (FTL_CSCMTQUOT) modernish bin/modernish init aborted in the fatal.sh battery with MSH_FTL_DEBUG silent: the battery's FTL_CSCMTQUOT probe (lib/modernish/adj/fatal.sh:514-518, the eval of ': || $( : # "\n)') died on a fabricated "unexpected EOF while looking for matching ')'" before any traceable statement. Receipt regression: the 166-probe modernish ledger (rubash#477) is dead on master - every capability probe returns 128 because init cannot even start. Bisect (rubash.exe direct, probe rc as classifier, good=7a2bfdf4, bad=41de8319): first bad commit 206dc04 (rubash#318), which introduced lexer::unclosed_comsub_eof_shape. The probe's scanner tracked quotes, escapes and parens but had NO comment branch: the in-comment double quote of the FTL_CSCMTQUOT string flipped its double-quote state, swallowed the newline and the closing ")", and the comsub stack entry never popped - ComsubEof - fabricated eval abort (execute_eval pre-probe in trap_exec.rs). GNU owner: parse.y:3630-3643 read_token -> parse_comment - a word-initial "#" comments out the rest of the physical line and comment text is discarded (quotes and parens are data); word-initial test at parse.y:3937-3940. Mirrors the CommentAwareScan boundary rules wt12 landed for the completeness scanners (7a2bfdf) onto the eval EOF probe. Fix: token_boundary state in unclosed_comsub_eof_shape (comment branch at token boundaries, newline left for the line counter, backslash escapes are word text), plus token_after_paren treating a word-initial "#" after the shifted function-definition paren as a comment (next token = newline). The None outcome is unchanged, so the "x=(" compound-assignment and "$(( " arithmetic families still defer to the generic close-char scan. Tests: tests/issue282_eval_probe_comment_regressions.rs - 7 script-file probes pinned byte-for-byte vs WSL GNU Bash 5.3.0, RED 5/7 on pre-fix master, GREEN 7/7 post-fix. Full cargo test --no-fail-fast failure set vs fresh master: identical by name, bidirectional (67 pre-existing environment-bound failures on both sides, none eval- or lexer-related). cargo fmt clean. Verified: modernish @63bdae02 LF clone + harvest goodsh patch - plain init silent rc=0 at GNU parity, with MSH_FTL_DEBUG tracing 157 lines through the battery's success path (was: rc=128, trace silent).
|
Independent verification (regression root-cause pass, clean clone Repro (RED) confirmed on fresh master d116874 — Bisect conclusion reproduced: parent 8064c2f probe rc=0 + init rc=0 (GOOD); first bad 206dc04 — probe fabricates EOF, init rc=128 (BAD). GREEN confirmed on this branch (054c654): plain init silent rc=0, byte-identical to GNU; 2/2 ecosuite fixtures byte+rc identical; new regression tests 7/7; Full Receipt rerun note: the full 166/166 capability-parity re-claim stays out of scope here as written in the description (current sweep: init-level parity + fixtures). One follow-up blocker found during verification and filed separately as #575 — |
Closes #282. P1-high: modernish is a published ecosystem receipt (166-probe ledger, rubash#477) - the fatal.sh battery abort killed the whole receipt on master (every capability probe rc=128, init cannot start).
Repro
LF modernish @63bdae02 clone + harvest goodsh patch; echo 'exit 0' | rubash bin/modernish->modernish: Fatal shell bug(s) detected, rc=128;MSH_FTL_DEBUG=1traced 4 lines, dying at the FTL_CSCMTQUOT probeeval ': || $( : # "\n)'(fatal.sh:514-518) with "unexpected EOF while looking for matching `)'". GNU Bash 5.3.0 (WSL oracle): silent rc=0.Bisect
git bisect runwith rubash.exe direct (probe rc classifier, good=7a2bfdf4, bad=41de8319): first bad commit 206dc04 (rubash#318) - it addedlexer::unclosed_comsub_eof_shape, a comment-blind scanner. Its parent 8064c2f is good.Root cause
The eval EOF-shape pre-probe (execute_eval, trap_exec.rs) tracked quotes/escapes/parens but had no
#comment branch. The in-comment"of the FTL_CSCMTQUOT string flipped its double-quote state, swallowed the newline AND the closing), the comsub stack entry never popped, and the probe fabricatedComsubEof- a fatal eval abort for input GNU parses cleanly.GNU owner: parse.y:3630-3643 (
read_token->parse_comment): a word-initial#comments out the rest of the physical line; comment text - quotes and parens included - is discarded (word-initial test :3937-3940). Same rules wt12 already landed for the completeness scanners (CommentAwareScan, 7a2bfdf); this ports them onto the eval probe.Fix
token_boundarystate inunclosed_comsub_eof_shape(comment branch at token boundaries; terminating newline left for the line counter; backslash-escaped chars are word text; boundary mirrors BraceScan's operator/whitespace idiom).token_after_paren: word-initial#after the shifted function-definition paren comments out the line, so the yacc error namesnewline.Noneoutcome is unchanged:x=(and$((still defer to the generic close-char scan (oracle-checked, incl.$((1 # 2))rc=1 and same-line$(echo a # b)plain-EOF).Tests
),$#word text, escaped-space, comment-hidden(with real unclosed comsub,echo ( # cnamingnewline). RED 5/7 on pre-fix master, GREEN 7/7.cargo test --no-fail-fast: failure set vs the PR-base master (1184c96) identical by name, bidirectional (54 pre-existing environment-bound failures on both sides - the /d-vs-D: path-form/bashdb/examples family; none eval- or lexer-related; the same comparison held 67=67 against the older base 41de831).cargo fmtclean. Rebased onto 1184c96 after master advanced (P1 Wave1: six semantic fixes (#524 #525 #529 #532 #535 #536) — trap exit unwind, pipeline redirect failures, indirect declared-unset, runtime bad substitution, redirect-word nounset, malformed subscripts #561-边界契约审计:三不变量契约测试 + windows-path-contract 文档 + 代理驱动指南 #570); probe and 7/7 tests re-verified GREEN post-rebase.modernish battery rerun (receipt)
echo 'exit 0' | rubash bin/modernish, LF 63bdae02 + harvest goodsh patch + MSH_SHELL=/usr/bin/bash): silent rc=0, byte-identical to GNU; with MSH_FTL_DEBUG the battery traces 157 lines through its success path (trap 'echo $PPID' 0->echo $PPID).localinheritance/quirk family), unreachable from this lexer change; on pre-fix master they all read rc=128 because init itself was dead. Re-claiming the full 166/166 README number needs its own capability-parity pass and is out of this PR's scope.License red lines: no license files touched, no new dependencies, no vendored-source changes.