Repository navigation
fix5 statelife3: assignment procsub value materialization (#1561) + PIPESTATUS indirect first-touch (#1566) - #1575
Merged
Merged
Conversation
…m span (rubash#1561)
A standalone assignment whose RHS is a process substitution kept
the literal span text as the value whenever the body's token-join
re-print diverged from the verbatim text (`>&2` re-prints as
`>& 2`; pipes, `;`, quoted redirect targets likewise). GNU
extract_process_subst (subst.c:1311) pulls the span verbatim from
the word string and process_substitute (subst.c:6362) splices the
/dev/fd result; assignment words receive process substitution
exactly like argument words (expand_word_internal,
subst.c:11349-11378).
Both assignment materialize channels spliced by the re-printed
metadata target and silently missed. They now share a splice-range
search: exact match at a cursor, then verbatim location verified
against the source re-print (new parser helper
verbatim_process_substitution_span, parse_matched_pair rules via
embedded_procsub_close), then from-zero retries covering metadata
order differing from word order. The raw channel still registers
only when the splice lands (rubash#1523 exactly-once is
preserved); the cooked channel keeps its register-on-miss
behavior, and exotic bodies that fail verification keep the old
outcome.
Regression: tests/issue1561_assignment_procsub_value_regressions.rs
(9 tests, GNU bash 5.3.20 expectations); activates the previously
#[ignore]d pin issue1557_inherited_fd_procsub_value. Gates:
issue1523 6/6, issue1557 14/14, lib 732 pass / 1 baseline fail,
246 differential failures {gl08, ms10} (stable set).
…#1566)
The keys form ${!PIPESTATUS[@]} as a first touch — and the plain,
element, and operator indirection forms after any command —
reported "invalid indirect expansion" and aborted the command.
The word error scan's existence oracle consulted only env_vars
and the variable table, but the PIPESTATUS array cell lives in
shell_state (set_pipestatus_array, variables.c:6291, writes the
ARRAY object directly); the keys expansion leg itself was already
state-aware and never got to run.
GNU parameter_brace_expand (subst.c:10016-10047) dispatches the
pure ${!name[@]} / ${!name[*]} keys form to array_keys before
parameter_brace_expand_indir ever runs, so that form never
validates the base: an absent name yields the empty key list,
even under set -u.
- New pipestatus_cell_exists: PIPESTATUS counts as existing
whenever its shape is not Absent (GNU's lazy-creation timeline:
materialized by the first completed command). Wired into the
plain leg's source_found, the operator-tail existence check,
and both base_exists arms of the subscript leg.
- The pure keys form (the [@]/[*] group closes the body) skips
the base-existence error entirely; an operator tail after the
group keeps the error, as GNU does.
- indirect_source_scalar_value reads PIPESTATUS element 0 from
the state cell; indirect_parameter_operator_value and the
[@]-operator t-join scan adjudicate PIPESTATUS through the
same sources (yielding GNU's "0 1: invalid variable name" for
${!PIPESTATUS[@]:-d} after a pipeline).
- Numeric indirect targets: index 0 designates $0, which lives
outside the $1.. positional window — the plain leg's numeric
arm read $1 via a saturating subtraction, and
indirect_target_values had no numeric arm at all, so a
PIPESTATUS indirection's target ("0") looked unset to the
operator adjudication. Both now resolve $0 through
script_name_value (subst.c:7955 re-expansion), with the plain
leg's leading-zero guard mirrored.
Genuine error forms are unchanged: ${!no_such}, ${!no_such[0]},
${!no_such[@]:-d}, and a literal first-command ${!PIPESTATUS}
still error byte-identically to GNU.
Regression:
tests/issue1566_pipestatus_indirect_first_touch_regressions.rs
(12 tests, GNU bash 5.3.20 expectations). Gates: issue1363
21/21, issue1364 12/12, issue1555 12/12, issue1556 13/13,
lib 732 pass / 1 baseline fail, 246 differential failures
{gl08, ms10} (stable set).
Member
Author
集成树复验(PR 开后补入)基线 master 门控复验(净化环境,剥离全部 JARVIS_*;构建配方 RUSTFLAGS="-C debuginfo=0" CARGO_BUILD_JOBS=1 CARGO_INCREMENTAL=0):
无超预期红项,无新残余。 合并归主会话把关。 |
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.
Fixes #1561
Fixes #1566
第五波 statelife3 簇集成片:两条状态生命周期残余修复,各一个 commit,自 statelife3 簇分支按序拣入当前 master(533cb4cf,零冲突;簇基线里的 #1555/#1556 cherry-pick 已随 #1570 合并,未重复拣入)。
#1561 — 赋值形 procsub 的值停留在字面文本
v=>(echo BODY >&2); echo "v=[$v]"→ GNUv=[/dev/fd/63],rubashv=[>(echo BODY >&2)]:body 恰好执行一次(#1523 收尾契约成立),只有值从未被拼接。根因在元数据扫描process_substitutions_in_word_with_raw构造的ProcessSubstitution.target是 token 再版印(>& 2),与原文 span(>&2)不一致时,raw 与 cooked 两个赋值物化通道都按目标串拼接、静默落空。修复:
src/parser/process_substitution.rs新增verbatim_process_substitution_span(引号/转义感知走查定位原文 span,命中须通过「其 body 再版印 == 元数据 source」身份校验);两个物化函数共用assignment_procsub_splice_range按游标精确 → verbatim → 从 0 的顺序找拼接范围,以字节范围 splice。raw 通道找不到仍continue不注册(#1523 exactly-once 原样保留);heredoc body /case…esac等异形 span 验证不过时保持旧行为,不构成回退。本片同时激活
tests/issue1557_inherited_fd_regressions.rs中预留的#[ignore]钉issue1557_inherited_fd_procsub_value(GNU 期望;v=>(echo BODY >&3)正是再版印发散形),并新增 issue1561 套件 9 测。#1566 —
${!PIPESTATUS[@]}首次触碰误报 invalid indirect expansion${!PIPESTATUS[@]}作为对 PIPESTATUS 的第一次触碰 →invalid indirect expansion、rc=1;未设名${!no_such[@]}同样误报(GNU 给空列表 rc=0)。展开腿本身是对的,错在词错误扫描indirect_parameter_word_error的存在性预言机只查 env 两张表,而 PIPESTATUS 的数组格活在shell_state的稀疏向量 +pipestatus_shape里,三条腿全误判缺失抢先致命报错。修复(全在
src/executor/parameter_errors.rs,另两处数值目标臂):新增pipestatus_cell_exists(shape != Absent 即存在,与 GNU 懒创建时间线对齐),plain/operator/下标三腿各加这一来源;纯 keys 形([@]/[*]恰好闭合整个 body)整体跳过 base 存在性报错(带 operator 尾不算纯 keys 形,报错保留);标量形/operator adjudication 改经状态格取值。另补数值目标再展开的两处 $0 缺口:PIPESTATUS element 0 几乎总是0,目标0指 $0——expand_braced_special数值臂原以saturating_sub(1)把 0 读成 $1,indirect_target_values则完全没有数值目标臂;两处补 index==0 →script_name_value()。真非法形态(${!no_such}、${!no_such[0]}、${!no_such[@]:-d}、字面第一命令的${!PIPESTATUS})逐字保留报错。新增 issue1566 套件 12 测,期望全部按 GNU bash 5.3.20 实测。
验证账本(簇侧,集成树复验随后以评论补入)
ownership_unary_operators_check_existing_file);246 差分 244 过、失败集 {gl08, ms10}。