Repository navigation
fix(executor): thread quote context into the #/% silent gate for list subjects - #3624
Merged
Merged
Conversation
… subjects (Refs #3581) A quoted "${a[*]#...}" / "${*#...}" with a single "" element must diagnose a bad substitution inside the pattern word: GNU marks the quoted-null list element QUOTED_NULL (subst.c:10133-10140), so the removal gate's empty test (subst.c:10320-10327) sees a non-empty word. rubash's gate read the joined "" as silent either way. - pattern_word_is_silent gains a 'quoted' flag; only the LIST-subject arms (@, *, name[@], name[*]) treat quoted as absent-only-silent — scalars/elements carry no QUOTED_NULL and stay silent quoted or not; an absent list stays silent either way (all GNU-verified). - The ${} fragment's quote context is read from EXTQUOTE_NAME_QUOTED_CONTEXT (embedded_parameters' in_double || double_quoted || heredoc record, rubash#2650) — heredoc counts as quoted (Q_HERE_DOCUMENT; GNU diagnoses "${a[*]#...}" in heredoc bodies too) — and the lexer's QUOTED_EXPANSION_SITE marker, now folded into that record at both walkers' $ dispatch. - The mutable walker upgrades a fragment's Unquoted context to DoubleQuoted when its own in_double/quoted_site says the fragment is inside quotes (mirror of the &self walker's record). - with_forked_heredoc_expansion now carries parameter_bad_substitution across the fork-emulation restore like the arithmetic latches: GNU's do_redirections runs in the forked child (execute_cmd.c:5522), so a heredoc-body bad substitution abandons the command (rc 1), it does not run with an empty expansion. Verified byte-identical to GNU bash on the full matrix: quoted/unquoted x list/scalar/element/bare-name subjects x absent/empty/nonempty, plus heredoc bodies ("..." and bare). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Nov 14, 2026
Closed
Member
Author
|
【WIN-AGENT-AUDIT】PR #3624 第1轮 — 建议:PASS 机制核查:
腿(逐项给数字与名字):
F 点:无。 未跑/VOID 的腿:
|
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3581.
Problem. Quoted
"${a[*]#...}"/"${*#...}"with a single""element was silent; GNU diagnosesbad substitutionfor the pattern word.GNU anchors. subst.c:10133-10140 — a quoted-null list element carries QUOTED_NULL, so the removal gate's
*value == '\\0'test (subst.c:10320-10327,case '#': case '%':) sees a non-empty word and expands the pattern. The gate's empty half therefore must be defeated by quoting ONLY for list subjects (@,*,name[@],name[*]): scalars/elements/bare names produce no QUOTED_NULL and stay silent quoted or not; an absent list stays silent either way. Heredoc bodies count as quoted context — GNU diagnoses"${a[*]#bad}"there too (Q_HERE_DOCUMENTbehaves quoted for list forms) and abandons the command (execute_cmd.c:5522 -> redir.c do_redirections in the forked child).Change.
pattern_word_is_silentgains aquotedflag; list-subject arms useempty_is_silent && !quoted.${}fragment's quote context is read fromEXTQUOTE_NAME_QUOTED_CONTEXT(in_double || double_quoted || heredocrecorded at each embedded-walker dispatch, rubash#2650) — extended to also fold in the lexer's QUOTED_EXPANSION_SITE marker on$expansions it saw inside quotes (the fragment's GNUquotedbit).in_double/quoted_site marks the fragment as quoted (mirror of the &self walker).with_forked_heredoc_expansionnow carriesparameter_bad_substitutionacross the fork-emulation restore like the arithmetic latches — previously a bad substitution inside a heredoc body printed the diagnostic but the command still ran.Verified. Byte-identical to GNU bash (5.1 oracle on this Linux box) on the full matrix: quoted/unquoted × list/scalar/element/bare-name × absent/empty/nonempty, plus heredoc bodies. New pin: tests/issue3581_quoted_removal_gate_regressions.rs (8 tests); issue3501_pattern_word_silent (68) still green.