Repository navigation
fix(expansion): only run compound expansion on parser-marked compound assignments (Refs #3034) - #3056
Merged
Conversation
…e (Refs #3034) Regression pin: tests/issue3034_assignment_paren_expansion_regressions.rs (13 cells). Quoted scalar words whose parens are literal data (y="($x)", y="(${x})", y='('"$x"')') must store the plain parenthesized value; the __git_ps1 detached chain (b="$(...)" then b="($b)", rubash#3005 root) must render ((v1.0)); genuine compound assignments (y=($x), y=("$x")) stay arrays. See the file header for the GNU anchors (parse.y:5648-5657, parse.y:7104, arrayfunc.c:557, subst.c:4357). Refs #3034
… assignments (Refs #3034) expand_compound_positional_at_assignment / expand_unquoted_parameter_compound_assignment implement GNU expand_compound_array_assignment (arrayfunc.c:557) but were called on ANY parenthesized value. A quoted scalar word such as y="($x)" — whose parens are literal data inside double quotes — was claimed as an element list, and its products ride the ARRAY_FIELD_SPLIT_MARKER-tagged field transport, which leaked verbatim into scalar storage: (\x10"v1.0") instead of (v1.0). Same shape via y='('"$x"')', argument words (echo "y=($x)"), and prefix assignments. Gate both claim calls on the parser's compound decision (COMPOUND_ASSIGNMENT_MARKER, U+E31A): only an unquoted '(' immediately after '=' starts parse_compound_assignment (parse.y:5648-5657, parse.y:7104); a quoted scalar takes the assignment-string path (subst.c:4357 expand_string_assignment). This is the root of #3005 (__git_ps1 detached chain). Regression pin: tests/issue3034_assignment_paren_expansion_regressions.rs (13 cells; fail-first on true base 30ddc12 = 2 passed / 10 failed, exactly the bug faces). Refs #3034
caomengxuan666
marked this pull request as ready for review
November 8, 2026 02:27
This was referenced Nov 8, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 9, 2026
…#3143) Fixes #2907 生态链钉入仓:真实 git contrib 脚本(git-completion.bash / git-prompt.sh,GPL 不入仓、宿主发现)的 live 入口端到端链钉——链 A 驱动已注册补全入口 `__git_wrap__git_main`(含 A15 直调 `__git_main`),链 B 在八态仓库上渲染 `__git_ps1`(含无参打印形与 pcmode 形);同仓库、同 driver 分别在 rubash 与 GNU bash 5.3.20 oracle 下运行,stdout 逐字节一致、stderr 归一脚本路径后逐字一致。同文件第二钉复核 mvdan-n 16 个解析夹具的 `-n` 退出码与 oracle 逐个一致(559 片段差分是否接 CI 仍归 #3033 裁定,本 PR 不预断)。本钉即 eco-2907 两处已修分歧的链级回归钉:B6 格 = #3034(PR #3056)真实命中形,A15 stderr 格 = #3035(PR #3047)真实命中形。 本 PR 删除了什么:无(纯测试与夹具新增)。净行数 +645/−0,4 文件:tests/issue2907_git_contrib_chain.rs、tests/fixtures/ecosuite/git-contrib/{driver,make-repos}.sh、tests/fixtures/ecosuite/MANIFEST.md。
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 #3034
现象
x=v1.0; y="($x)"; printf '%s' "$y" | od -An -tx1:GNU 存(v1.0),rubash 存
(\x10"v1.0")——泄漏ARRAY_FIELD_SPLIT_MARKER(0x10)+一对存储引号。同样泄漏:
y="(${x})"、y='('$x')'、多展开、含空格值、链式
y2="($y)"、参数形词echo "y=($x)"、前缀赋值、eval。这是#3005(
__git_ps1分离头症状)之根:b="$(git describe …)"; b="($b)"的第二步即此形状。
根因
复合认领(compound-claim)调用缺失复合判定。
expand_compound_positional_at_assignment/expand_unquoted_parameter_compound_assignment实现 GNUexpand_compound_array_assignment(arrayfunc.c:557),却被调用在任何括号形值上:三处赋值展开调用点(
assignment_expansion.rs的expand_assignment_value_inner、expand_word.rs的expand_plain_assignment_word、parameter_core.rs的expand_word_mut_with_context)认领前从不查解析器的复合判定。y="($x)"的(在引号内、不是复合赋值,却被认领为元素表,其compound_field_split_transport产物\x10"v1.0"(assignment_helpers.rs:976)不经拆分/解码就原样存为标量值。
仪器证据(基底二进制,
RUBASH_DBG_AAV=1):[ECPAT] value="($x)" expanded="(\u{10}\"v1.0\")"。修法
三处调用点统一加复合认领门:仅当值带
COMPOUND_ASSIGNMENT_MARKER(U+E31A)时才调用两只复合展开函数;否则落入一般赋值串展开
(
subst.c:4357expand_string_assignment)。门用的就是解析器自己的复合判定(GNU 的同一判定),即「复合展开只跑在解析器已判定为复合赋值
的词上」这一不变量——不是症状黑名单。门内 marker 拼回保持原样。
未动:
eval的 bare-flatten、declare -a d="(a b)"的 declare 重解析路径、
continuation.rs、docs/api-ledger.md。GNU 锚点
parse.y:5648-5657read_token_word(复合判定:仅=后紧跟未引用(才进parse_compound_assignment)parse.y:7104parse_compound_assignmentarrayfunc.c:557expand_compound_array_assignmentsubst.c:4357expand_string_assignment本 PR 删除了什么
无删除。 本 PR 只做加法与门控收窄:
COMPOUND_ASSIGNMENT_MARKER的括号词不再进入复合展开——这正是被修的 bug 本身(此前误认领的路径)。
−43 行中无整段删除,均为门内化简(
if compound_assignment { marker } else { "" }在门内恒真,化为直接拼 marker)与注释调整。
车道自验证据
tests/issue3034_assignment_paren_expansion_regressions.rs(12 个
#[test]/ 17 处字节断言):fail-first(基底 worktree30ddc122+ 移植钉)2 passed / 10 failed,失败恰为全部 bug 面;修后 12 passed / 0 failed。
fd6e13e51197/0/4 = 基底30ddc1221197/0/4,逐数对齐。
array_store_parity 4/0、assignment_quote_roundtrip 4/0、
assignment_chain 9/0、assign_prefix_subshell 1/0、issue1113 8/0)。
RUSTFLAGS="-D warnings" cargo check --locked --lib --binsrc=0;bash scripts/check-utf8-boundary-hygiene.shclean rc=0;cargo fmt --checkrc=0;改动文件无 CR。od逐字节):23 形全 SAME(全部泄漏形 + 真复合仍为数组 + declare/local/
a+=(2)/$@对照)。isolate-b6.shstdout/stderr 与 GNU逐字节一致;真实
__git_ps1 '(%s)'(detached HEAD)两壳均为((v1.0))\n(282876312e302929)。__git_ps1 分离头描述值泄漏载体字节 U+0010 与引号(t9903 六例) #3005 症状在真链上消失。备注
30ddc122;车道飞行中 master 已前进至a7d3176f(fix: set listing of scalars with bare C0 bytes lacks $'...' quoting #3017/[test-harness] Input process-substitution child resolves its exe without the test-binary fallback #2875/[bug] error inside a sourced-file function reports the top-level script filename #3035 合入),rebase 由合入时处理。
d7d5d400正文「13 cells」为笔误,实为 12 个#[test]/17 处断言;本正文与 REPORT 以 12/17 为准。