Repository navigation
fix(executor): resolve ${!src<op>tail} indirection for positional and special sources - #3747
Conversation
… special sources (Refs #3605) ${!1:-d}, ${!#:-d}, ${!?-d}, ${!@:-d}, ${!*:-d} and friends: GNU parameter_brace_expand_indir (subst.c:7883-7952) resolves ANY parameter kind through parameter_brace_find_indir — positional text, the $# count, the $? status, joined positionals for @/*, the script name for 0 — then applies the operator word to the parameter t names. Only a valid-identifier source with NO tail earns 'invalid indirect expansion' (subst.c:7907-7918); an unresolvable tail-less source proceeds silently; a resolved-but-invalid target reports '<t>: invalid variable name' (subst.c:7947). - is_valid_indirect_expression: admit #/?/@/* heads carrying an operator tail (want_indir VALID_INDIR_PARAM, subst.c:122/9920). - indirect_parameter_operator_value: unify #/?/@/* and positional sources through parameter_error_value so '0' resolves to the script name instead of positional 1. - has_indirect_parameter_word_operator: a leading #/?/@/* is the indirect SOURCE itself, never a pattern-open — ${!#:-d} is indirection through $# under :-, not $! minus a prefix. - expand_braced_operator_or_array_parameter '?' arm: outside posix mode '!'+'?' is an indirect source, not $! under '?' — the following -/=/+/: split owns that form. - is_parameter_error_name: admit '!'-led digit and special heads. - expand_braced_special '#' arm: ${!#} indirects through the $# VALUE — with zero positionals t='0' names the script name. - Operator-tail diagnostics resolve t via parameter_error_value for digit/special heads; a bare ${!0} reports the script-name target. Verified byte-for-byte vs GNU bash 5.3.20 across script and -c modes (errors6.sub now identical; 13-pin test issue3605_indirect_special_source). Residuals noted on the issue: -c-mode $? starts at 1 (separate init gap) and the posix-mode fatal-builtin-error semantics in errors11.sub (different subsystem). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】PR #3747 第1轮 — 建议:FAIL 机制核查:
F 点:
腿(逐项给数字与名字):
未跑/VOID 的腿:无 处置:不合、不关单,等返工(补 |
…t ^,
Audit follow-up: is_valid_indirect_expression had admitted the whole
`: - + = ? # % / ^ , @` tail class for `!`+special/digit heads while
only the `:- - + = ?` operators were implemented, turning GNU's
defined semantics (and its bad-substitution errors) into silent
empty output.
- Tail class narrowed to the class string_extract scans after a
`!`+special head — `#%:-=?+/@` (subst.c:9844-9860). `^`/`,` on
special/digit heads (`${!#^}`, `${!#,}`, `${!#^2}`) are bad
substitution again.
- `!`+`#?@*`/digit heads with `/`,`%`,`:`(non-`-=?+`) or `@` tails
resolve t = the parameter the source VALUE names and re-dispatch
the operator on t (parameter_brace_find_indir, subst.c:7839-7881,
feeding parameter ops at :9978-10017):
- expand_braced_special resynthesizes `${t tail}`;
- indirect_substring_parameter resolves `:off:len` through t;
- indirect_replacement_parameter re-dispatches `${t/pat/rep}`;
- indirect_parameter_transform re-dispatches `${t@op}`;
- indirect_holder_target_name: `#` -> positional count, `?` ->
status, `@`/`*` -> joined value, `0` -> script name (not
positional_window[0]).
- `${0<op>}` routes to script_name_value in the replacement and
transform digit arms (subst.c:9424-9428 name-first lookup).
- An unset indirect target under `@op` renders NULL (subst.c:8927),
not the quoted-empty `''` a set-empty cell earns.
- zero_reports_script_name_as_target pin moved to script-file form.
29-case matrix (F1+F2+probes) byte-identical to GNU bash 5.3.20
stdout+stderr+rc; pins 18/18; adjacent slices green; fmt/marker-lint
clean. Refs #3605
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
对 FAIL(comment 6914442298)的返工已推:head F1( F2(
审计全形逐格(GNU /usr/local/bin/bash 5.3.20 对照,macOS arm64)—— F3(钉形态) — 已知残差(非本 PR 面,均未修):rubash startup 腿:pin 18/18 绿;issue1147/2608/2649/2712/529/439/1091_1092_1093/1910/1927/3022/3501/843/371/parameter_transform_tests 全绿;rustfmt/marker-lint(117 consts, 268 sites)净。 |
|
【WIN-AGENT-AUDIT】PR #3747 第2轮 — 建议:FAIL 机制核查:
腿(逐项数字):
F 点:
续作记录:本轮为验证轮,未动代码;前轮返工 commit f6d075f 已在远端 head。 未跑/VOID 的腿:无。 |
|
【WIN-AGENT-AUDIT】PR #3747 第3轮 — 建议:FAIL(维持第2轮判词,F1 复现确认且范围比审计描述更宽) head 与第2轮 FAIL 判定时完全一致(gh api 复核未动),未重跑全腿;F1 用 WSL GNU bash 5.3.20(1)-release(/usr/local/bin/bash,x86_64-pc-linux-gnu)脚本文件对照复现,探针 target/u1-probes/indir3747*.sh(LF 落盘): 机制核查:
GNU 对照实测矩阵(rubash head f6d075f vs WSL bash 5.3.20,同脚本文件):
要点修正第2轮描述:
腿:
F 点:
续作记录:本轮为验证轮,未动代码。 |
|
【WIN-AGENT-AUDIT】x3 续作开工 本 lane(x3)接手第3轮 FAIL 的 F1 返工: 计划:checkout devin/indirect-special-source @f6d075fd → WSL 5.3 对照复现 named/digit/special 三源 × ?/:? → 按机制修(resolved-t 判定,非个案补丁)→ 钉补格 → 钉自跑 + fail-first + lib 双边 + 警告门 → push 新 commit(不改写历史)→ REWORK 报告。 |
…3605) A `?`/`:?` tail on a `!`-indirect source was adjudicated against the raw `!src` name, so a set target aborted: `u=x; x=hello; echo ${!u?v}` reported `!u: v`. GNU resolves t first — parameter_brace_expand_indir (subst.c:7883-7952) -> parameter_brace_find_indir (subst.c:7839-7881) produces the source value, parameter_brace_expand_word(t) (subst.c:7907) produces the value the operator tests, and only a null temp takes the report arm, which still names the ORIGINAL expression (subst.c:10412 parameter_brace_expand_error). scan_question_is_error now routes `!`-indirect names through indirect_parameter_operator_value (the same two-step resolution the `-`/`+`/`=` family already used) before the set/null verdict. Verified against WSL GNU bash 5.3.20 from script files on 20 shapes (named/digit/special source x ?/:? x set/unset/empty, plus the `!?`/`@`/`*` and invalid-target arms); pin issue3605_indirect_special_source 20/20 (13 red at merge-base).
… split (Refs #3605) `${!??v}` / `${!?:?v}`: the first `?` is the indirect SOURCE ($?, subst.c:122 VALID_INDIR_PARAM / subst.c:9920 want_indir), so the `?` error operator is the NEXT character. The operator family's `split_once_outside_subscript(name, '?')` took the source byte for the operator, leaving subject `!` and returning an empty value: GNU resolves `$?` -> "0" -> `$0` through parameter_brace_find_indir (subst.c:7839-7881) + parameter_brace_expand_word(t) (subst.c:7907) and prints the shell name. Re-split a `!?`-headed name at the operator `?` and pass the two-character subject `!?` through parameter_operator_value — the same two-step resolution `${!?}` (bare) already uses. Verified against WSL GNU bash 5.3.20 from a script file (22-shape matrix of named/digit/special sources x ?/:? x set/unset/null) byte-identical stdout/stderr/rc. Pin issue3605_indirect_special_source 21/21; the new case is bad substitution at the branch's base commit.
|
【o1 收网验证 · 建议 PASS】head F1 逐条回应(第3轮 FAIL):
GNU 对照:WSL GNU bash 5.3.20 脚本文件 22 形状矩阵(named/digit/special × ?/:? × set/unset/null,含 腿(Windows):
关联 #3605:伞目录,保持 OPEN。未跑腿:WSL Linux 原生构建(本改动非 unix-gated/fd 族)。 |
Summary
run-errors/errors6.subivar -3divergence:${!src<op>tail}indirections whose source is a positional index or aVALID_INDIR_PARAMspecial (#,?,@,*) were misclaimed —${!#:-d}produced empty instead ofb,${!?-d}printed the default word instead of the script name,${!0}read positional 1, and the diagnostic arms couldn't name a digit/special head's resolvedt.GNU anchors (subst.c):
want_indir(:9920-9922) +VALID_INDIR_PARAM(:122);parameter_brace_expand_indir(:7883-7952) resolves every parameter kind throughparameter_brace_find_indir(:7839-7881) — the$#count,$?status, joined positionals,$0script name — then applies the operator to the parametertnames (:9978-10017).is_valid_indirect_expression:#/?/@/*heads with an operator tail are legal indirections; the tail class is narrowed to whatstring_extractscans after a!+special head —#%:-=?+/@(:9844-9860), so^/,tails on special/digit heads staybad substitution.indirect_parameter_operator_value: unify special/positional sources throughparameter_error_value("0"-> script name, not$1).has_indirect_parameter_word_operator: a leading#/?/@/*is the source, never a pattern-open.expand_braced_operator_or_array_parameter?arm: non-posix!+?is an indirect source, not$!under?.expand_braced_special#arm:${!#}indirects through the$#value — zero positionals names$0;!+special heads carrying a#%/@/substring tail resynthesize${t tail}and re-dispatch.indirect_substring_parameter/indirect_replacement_parameter/indirect_parameter_transform: special/digit heads resolvetand re-dispatch${t<op>}—${!#:0:1}->${2:0:1}->b,${!?/a/Q}==${0/a/Q},${!#@Q}->'b'.indirect_holder_target_name:#-> positional count,?-> status,@/*-> joined value, digits -> positional,0-> script name.${0<op>}routes toscript_name_valuein the replacement and transform digit arms (:9424-9428 name-first lookup).@oprenders NULL (:8927), not''.tfor digit/special heads; bare${!0}reports<script>: invalid variable name.Verification
errors6.subbyte-identical to GNU bash 5.3.20 (stdout + stderr), includingivar -3->-3: invalid variable nameand thex=-3/invalid-identrows.^/,errors + F2/ % : :offset @(…)tails + probes) byte-identical to GNU bash 5.3.20 stdout+stderr+rc on macOS arm64.tests/issue3605_indirect_special_source.rs(18 tests), including script-file form for${!0}. Regression slices green (issue1147/2608/2649/2712/529/439/1091_1092_1093/1910/1927/3022/3501/843/371/parameter_transform_tests);issue323/issue1566failures reproduce on the base commit (pre-existing, unrelated).run-errorsresiduals are independent roots noted on the issue:-c-mode$?init, posix fatal-builtin-error semantics inerrors11.sub,${#array}underset -u, and/bin/sh-boundsh:lines.Refs #3605
本 PR 删除了什么
scan_question_is_error的间接判定分支、!?源在 operator 家族的重新切分,以及tests/issue3605_indirect_special_source.rs的 21 格钉;未删除任何既有代码路径或测试。