Repository navigation
fix(unset): resolve indexed subscripts arith-grade, keep the raw ~ - #3590
Conversation
GNU array_expand_index (arrayfunc.c:1353-1368) resolves an indexed
subscript through expand_arith_string (subst.c:3981) — parameter,
command and arithmetic expansion, no tilde — so unset 'a[~]' reaches
evalexp with the raw ~ and expr.c's operand-expected diagnostic echoes
'~' verbatim. Rubash resolved indexed subscripts through the
assoc-grade expand_subscript_string, whose leading-~ step tilde-
expanded to $HOME first, so the diagnostic printed the home path
(rubash#3582).
Split the resolve by grade: eval_indexed_subscript{,_deferred} now use
resolve_indexed_subscript (expand_arith_string analogue, tilde step
skipped); assoc consumers keep expand_subscript_string, which DOES
tilde-expand a leading unquoted ~ (subst.c:11063 -> expand_word_internal;
'declare -A h=([$HOME]=v); unset h[~]' removes that key on GNU). The
cross-pass resolve memo keys now carry a grade tag so an assoc resolve
can never serve an indexed site.
Verified: vendored bash 5.3.20 byte-identical on the repro plus
'c[~]=9', '${a[~]}', 'a[\\~]', 'unset a[~x]', assoc 'h[~]'.
GNU cite: arrayfunc.c:1368 expand_arith_string; subst.c:11063
expand_subscript_string; expr.c:1120 operand expected.
Fixes #3582
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 机制核查(机制本身正确):
腿(逐项):
CI 按名核查 @e61cf6ca:
F 点:
重叠疑点(按分工单条注意上报,不改判):
续作记录:无。 |
|
【队长终裁】FAIL 核过审计报告(6886507707)+ CI 全表。机制本身正确(GNU arrayfunc.c:1353-1368,indexed/assoc 分级拆分与 GNU 一致;oracle 双形状核到)。F1 成立且为 PR 引入: |
Keep both mechanisms in eval_indexed_subscript: #3608's expand gate (Protected subscripts still take the single eval-time expansion pass) and #3590's arith-grade resolve dispatch (resolve_indexed_subscript / expand_arith_string, no tilde — arrayfunc.c:1368). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
check-marker-literals.py L2 flagged the bare "\u{0}" grade prefix in
resolve_array_subscript_with. Declare SUBSCRIPT_ARITH_GRADE_TAG in
markers.rs alongside the CASE_PATTERN_* NUL-prefix sentinels (same
non-user-reachable argument: NUL cannot appear in transport text) and
register its MARKERS row plus the internal-only / out-of-scope test
lists. Memo-key value is unchanged, so SUB_RES_XPASS semantics are
identical.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【REWORK】F1 已修 + master 已合(两轮),头 c7ee140 F1(marker-lint 红):按终裁走 registry const 路线—— 合并:origin/master 两轮——aea5b152(含 #3608 4e2c529)冲突仅 eval_indexed_subscript 3 行,按裁断两机制全保留:#3608 腿(全在 c7ee140 上重验):
CI 预期:上轮红在 check-marker-literals.py 步,现已净;lib 步若红应见 issue2875 签名(bin 未预建),与基线一致。 |
|
【WIN-AGENT-AUDIT】 本轮做了什么:f3590 lane 的 F1 返工(c200cd211 registry const)+ 两轮 master 合并已就位;本轮把 head 再并到现尖 c3bf91e(merge-tree 零冲突,自动合并),在新 head 上重跑全腿。 机制核查:
腿(全在 07f0212 上重跑):
F 点:无。 续作记录(本轮):
未跑/VOID 的腿:无。 |
|
【WIN-AGENT-AUDIT】
阻塞项(需队长): 环境备注:本轮 git fetch 因代理故障失败,远端 head 以 |
Summary
GNU array_expand_index (arrayfunc.c:1353-1368) resolves an indexed
subscript through expand_arith_string (subst.c:3981) — parameter,
command and arithmetic expansion, no tilde — so unset 'a[
]' reaches' verbatim. Rubash resolved indexed subscripts through theevalexp with the raw ~ and expr.c's operand-expected diagnostic echoes
'
assoc-grade expand_subscript_string, whose leading-~ step tilde-
expanded to $HOME first, so the diagnostic printed the home path
(rubash#3582).
Split the resolve by grade: eval_indexed_subscript{,_deferred} now use
resolve_indexed_subscript (expand_arith_string analogue, tilde step
skipped); assoc consumers keep expand_subscript_string, which DOES
tilde-expand a leading unquoted ~ (subst.c:11063 -> expand_word_internal;
'declare -A h=([$HOME]=v); unset h[~]' removes that key on GNU). The
cross-pass resolve memo keys now carry a grade tag so an assoc resolve
can never serve an indexed site.
Verified: vendored bash 5.3.20 byte-identical on the repro plus
'c[
]=9', '${a[]}', 'a[\~]', 'unset a[x]', assoc 'h[]'.GNU cite: arrayfunc.c:1368 expand_arith_string; subst.c:11063
expand_subscript_string; expr.c:1120 operand expected.
Fixes #3582
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>