Repository navigation
test: add fail-first regression pins for indirect expansion on name 0 (Refs #3784) - #3795
Conversation
… (Refs #3784) GNU anchors (bash 5.3 subst.c): parameter_brace_expand_indir (subst.c:7883) resolves t via parameter_brace_find_indir (subst.c:7839); an invalid t reports '<t>: invalid variable name' (subst.c:7947). ${!0}/${!00} indirect through $0's value (the shell path); ${!#} with $#=0 resolves through name "0", i.e. $0. UNVERIFIED-BY-CAPTAIN
|
【Y3-AUDIT】PR #3795 第1轮 — 建议:PENDING(缺修法腿:钉已验证合格且 fail-first 有效,但产品修法未落,合入会带进 10 条新红) 机制核查:
腿:
钉质量专项:断言分层正确(stdout 空 + 诊断词 + $0 名 + 排除 bad substitution + rc);控制格覆盖「GNU 同样为空」的边界,非假绿形态;17 钉与 issue 两面一一对应。 F 点:无(钉本身) 未跑/VOID 的腿:lib 双边与独立 base fail-first 构建(diff 仅 +tests/ 文件,构造性等价) |
…ails (Refs #3784) GNU parameter_brace_find_indir (subst.c:7839-7881) resolves every source kind to `t` before the operator applies (subst.c:7883-7952), and a positional source resolves through the parameter itself: - all-zero spellings (`${!0}`, `${!00}`, `${!000}`) name `$0` — the script name — never positional_window[0] and never a variable lookup (the leading-zero guard treated `00` as a NAME, so it silently expanded empty instead of reporting `<t>: invalid variable name`); - any other leading-zero text (`${!010}`) stays a variable name, as GNU does (empty when unset), so the guard is now `index == 0` rather than a raw `== "0"` string test; - `${!#%pat}` resolves the `#` holder through indirect_holder_target_name (count -> `0` with no arguments -> script name) instead of requiring a plain shell name, so the removal applies to `${0%pat}` / `${N%pat}`; - the error scan and the operator resolution share the same rule. Partial: `issue3784_indirect_expansion_zero` 14/17. Still open: `${!00-unset}` (the `-` operator arm never routes through the indirect target) and the quoted `"${!#%*}"` argument shape (unquoted form is correct) — both documented on the PR. GNU oracle: WSL bash 5.3.20(1) script files (target/probe3784.sh, target/p7.sh, target/p8.sh) for the leading-zero and holder shapes.
|
【o1 收网】判词 PENDING(14/17,剩 2 个根因):新 commit head 3b15a47(父 = 3d371fb + 合入 origin/master);关联 #3784 保持 OPEN。 已修(GNU 锚点:subst.c:7839-7881 parameter_brace_find_indir → :7883-7952 parameter_brace_expand_indir)
仍红 3 格(2 个根因,未修,已定位)
腿
未跑/VOID:lib 双边、warnings、CI 逐格、剩余 3 格的修复。判 PENDING:钉未全绿,不合入。 |
… (Refs #3784) parameter_brace_find_indir (subst.c:7839) expands the source through parameter_brace_expand_word, whose valid_number branch (general.c:248 -> subst.c:7684) reads get_dollar_var_value (subst.c:3707): index 0 is $0, never positional $1. `00`/`000` are numerically 0 and name $0 too, and leading zeros are otherwise insignificant (`x=010; ${!x}` is $10 — GNU 5.3.20 probe). The bare `${!0}` path used positional_window[index-1], so it read $1 (usually empty); the same source feeds every operator through get_var_and_type (subst.c:8529), so pattern removal, case modification, substring, `:=` binding and the subst.c:10164 nounset bound check now resolve the holder first and share one numeric_parameter_value lookup. Also gate the `${!prefix*}`/`${!prefix@}` name-list fast path on legal_variable_starter (subst.c:9974): `${!#%*}` is the `%` operator on `${!#}`, never a variable-name list. Tests: tests/issue3784_indirect_expansion_zero.rs (29 pins) plus the indirect/parameter/array regression files.
|
【o1 收网验证 · 建议 PASS】head 接手时远端已从审计时的 机制核查(GNU 锚点):
腿:
关联 #3784:本 PR 覆盖该 issue 两个 face 的全部形状( |
根因
rubash #3784:${!...} 间接展开对名字 0 的两面错误。
<$0>: invalid variable name、rc 1、无 stdout;rubash 现静默展空、rc 0。GNU 锚点
bash 5.3 subst.c(vendored tree):
parameter_brace_expand_indir(subst.c:7883):t 来自parameter_brace_find_indir(subst.c:7839),即展开源参数本身——名字0/00对应 $0 的值,#对应 $# 的值(无参数时为"0",即 $0)。valid_brace_expansion_word(subst.c:7583)判定,报<t>: invalid variable name(subst.c:7947);该错误对非交互 shell 是致命的(subst.c:4296 exp_jump_to_top_level)。本 PR 删除了什么
无删除。本 PR 只新增回归钉文件
tests/issue3784_indirect_expansion_zero.rs(17 个测试,覆盖两面 + 边界对照);产品代码未动。状态
UNVERIFIED-BY-CAPTAIN — 钉为 fail-first,待 X299 构建验证后上修法。
Refs #3784