Repository navigation
fix(glob,cond): protect full GNU glob-char class at [[ == ]] and pathname-glob boundaries (Fixes #4126) - #4262
Conversation
|
Captain review — needs rework, cannot merge as-is. Credit where it's due: the 7 new pins all execute and pass, and every #4126 face is genuinely closed on this tree. The GNU references check out word for word (pathexp.c glob_char_p, parse.y:5694-5706, subst.c quote/dequote_string). But the census says no: 46 FAIL, 38 of them new regressions, all inside the touched domain — issue2227 ×7, issue2999 ×7, issue868 ×6, issue2830 ×4, issue2441 ×3, issue876 ×3, issue3089 ×2, issue734 ×2, issue1540/2577, plus two single tests. The same-day sibling PRs sit at 7–9 FAIL, so this isn't baseline drift. Root cause: R1 (blocking): narrow the marking surface, or make every downstream consumer CTLESC-aware — pick one, not both. (a) Pull R2 (blocking): R3 (blocking or split out): the pipeline_exec stage-expansion refactor. Deleting per-operand glob expansion in the cat segment and trusting stage-expanded argv is a second change bundled into this PR — if Keep the 7 #4126 pins green through the rework — the faces they close are real. |
be2601c to
ecfd424
Compare
|
Reworked per Captain review (R1(a) + R2 + R3) and rebased onto Review Resolutions
Verification (WSL Linux + Windows + GNU Bash 5.3.20)
Fresh CI is running now. |
|
Captain re-review — rework passed, ready to merge after a rebase. This is not a narrowing of the old patch — the author rebuilt the approach entirely. The wide lexer marking (
The 7 #4126 pins all ran PASS by name in the census log, plus new conditional/pathname/ One remaining step before merge: please rebase onto current master. The PR base is still |
…name-glob boundaries (Fixes #4126)
ecfd424 to
462cf87
Compare
Summary
Complete the remaining quoted/escaped pattern metacharacter faces for #4126 (
[[ == ]]and pathname globbing across single/double/ANSI-C quotes) at the pattern/glob-entry boundaries without widening general lexer token values, and relocate the top-levelissue4126test binary into theissues_3900_4199bucket (Fixes #4126).GNU C Specification
[[ == ]]:third_party/bash/pathexp.c:163-196(glob_char_p()/glob_quote_char()),:212(quote_string_for_globbing()),subst.c:4077(cond_expand_word()),execute_cmd.c:3975(execute_cond_node()).third_party/bash/subst.c:4773(quote_string()),pathexp.c:66(unquoted_glob_pattern_p()),pathexp.c:163-190(glob_char_p()),pathexp.c:212(quote_string_for_globbing()),lib/glob/sm_loop.c:397,413-418(BRACKMATCH()),subst.c:4807(dequote_string()).Changes
src/executor/conditional.rs:append_literal_glob_textto escape the full GNUglob_quote_charclass (],-,!,^,+,@,.,:,=,#,%in addition to*,?,[,\,(,),|), so[[ $c == ["^"a] ]],[[ $c == ["!"a] ]],[[ $c == ["[]"] ]], and[[ $c == [a"-"z] ]]match GNU Bash 5.3.20.src/executor/glob.rs+ pathname-glob entry points (command_prepare.rs,command_words.rs,expand_word.rs,pipeline_exec.rs,pipeline_stages.rs):source_literal_glob_patterninsrc/executor/glob.rs(admitting only literal-only words with'...',"...",$'...',\c, rejecting expansions/braces/tilde/procsub) that CTLESC-protects quoted characters strictly on the pattern passed topathname_expand_word, leaving general lexer token values untouched.compound_element_glob_patternto decode and protect$'...'bytes (a=([a$'\x5d'b])).source_literal_glob_patterninto simple command argv,forwords, redirection targets, pipeline stage argv /catoperands, andlastpipestages.tests/issues_3900_4199.rs+tests/issues_3900_4199/issue4126_quoted_pattern_chars.rs:tests/issue4126_quoted_pattern_chars.rsintotests/issues_3900_4199/(per [1.6.0 Freeze] 架构与工程硬伤治理总纲(双轨并行:1.5.x 止血 + 1.6.0 结构收口) #4210/refactor(tests): consolidate 1,661 top-level issue*.rs tests into 17 grouped integration crates #4219) and expanded coverage across all 4 faces, ANSI-C\x5d/\x2d, UTF-8 subjects, quoted character-class syntax ([[":"alpha:]]), and heredoc/herestring dequoting.What this PR deletes
tests/issue4126_quoted_pattern_chars.rsintegration binary by relocating it intotests/issues_3900_4199/.Verification
/usr/local/bin/bash): 4-face matrix (parameter patterns,case,[[ == ]], casemod, pathname globbing across argv/for/compound arrays/redirections/pipelines with"",'',$'\x5d',$'\x2d',[[":"alpha:]]): 100% byte-exact (0-byte diff).RUSTFLAGS="-D warnings" cargo check --lib --locked: clean (0 warnings).cargo test --test issues_3900_4199 issue4126 --locked: 7/7 passed.cargo test --test lexer_quote_tests --locked(unmodified): 16/16 passed.cargo test --test parser_redirection_tests --locked: 68/68 passed.issue73415/15,issue8687/7,issue8767/7,issue15409/9,issue222710/10,issue24416/6,issue25772/2,issue28305/5,issue299915/15,issue308933/33): 0 failures.RUSTFLAGS="-D warnings" cargo check --lib --locked: clean (0 warnings).cargo test --lib --locked: 1,450/1,450 passed.python scripts/check-rustfmt.py,check-marker-literals.py,check-api-ledger.py: all clean.Fixes #4126