Repository navigation
fix(local): walk local -p operands once, in order (Fixes #3529) - #3548
Merged
Merged
Conversation
…ame_attributes (Refs #3529) GNU builtins/declare.def:389-406 (declare_internal, pflag branch with local_var) calls builtins/setattr.def:555 show_localname_attributes on each operand word verbatim, in order: a local of the current variable context prints (`local -` for the option-snapshot local), every other word is `not found` and fails the command; -g does not enter the lookup. execute_local used a pre-pass that reported missing plain names first, then skipped the declare-printer call whenever no plain name survived, so `local -p nope1 -x` never reported `-x`; it also printed `local -` ahead of every other operand and, under -g, unshadowed the frame local so the printer showed the global. A dedicated print route now walks the operands in order and renders each run of found names through the same declare printer; the old pre-pass and its status plumbing are removed. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
marked this pull request as ready for review
November 14, 2026 05:06
caomengxuan666
marked this pull request as draft
November 14, 2026 05:09
This was referenced Nov 14, 2026
Member
Author
|
【WIN-AGENT-AUDIT】 PR #3548 第1轮 — 建议:PASS 机制核查:
腿:
F 点:无 未跑/VOID 的腿:无(lib base 集复用同 merge-base 实跑结果)。 |
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.
修了什么
local -p NAME...改为 GNU 的单趟、按操作数顺序处理:每个操作数逐字查「当前变量上下文的局部变量」,找到就打印(option 快照局部打印local -),否则报not found并令命令失败。由此对齐:local -p nope1 -x:修前漏报-x(预扫后无剩余普通名就跳过核心调用),现报nope1、-x两行,rc 1。local -p x --help:master 上已一致,钉住防回退。local -p nope1 nope2 -x nope3/local -p a -x b nope:修前缺失的普通名被提前到所有诊断之前(stderr 顺序错),现按操作数顺序。local -p nope +x --:修前+x、--被吞,现逐个报 not found。local -; local -p x - x:修前local -总是最先打印,现按位置打印。local -g -p x:修前-g让核心看到全局值(打印x="g"),GNU 的 show_localname_attributes 不看-g,现打印帧内局部x="1"。机制:
execute_local新增 print 路由(-p且有操作数时进入)execute_local_print_operands:按local_operands取选项区之后的后缀,逐个判定;连续的找到名作为一段,经同一个 declare 打印核心(execute_with_io_named_in_context)渲染,因此 stdout/stderr 各自保持操作数顺序。删了什么
execute_local通用路由里的-p预扫(print_missing收集 + 先行报错 +args.retain过滤)及其在两处 status 计算里的分支。无操作数的local/local -p列表路径不变(其改写出的名字全部来自当前帧,预扫本来就无事可做)。GNU 依据
builtins/declare.def:389-406 declare_internal():if (pflag)分支for (...; list; list = list->next),local_var时调show_localname_attributes (list->word->word, nodefs),返回非 0 则sh_notfound+any_failed++。builtins/setattr.def:555-572 show_localname_attributes():find_variable_noref (name)逐字查找,local_p (var) && var->context == variable_context才打印;-打印local -。不读-g。验证
tests/issue3529_local_p_operand_order.rs(7 格,期望全部取自 WSL GNU 5.3.20 脚本文件实测,stdout/stderr 分开断言):修前 2 passed / 5 failed,修后 7/7。lpall.sh(覆盖上列全部形状):修后 rubash 与 GNU stdout、stderr 逐字相同(stderr 仅路径前缀归一)。cargo test --lib local30/30,--lib declare7/7。varenv.tests(含 varenv25.sub 的local -p;拷贝 tests 目录运行,diff --strip-trailing-cr):修前 17 / 修后 17 差异行,输出逐字节相同(17 行为 master 既有残差:assoc 顺序、varenv19 readonly、global:bcde组)。cargo fmt --check因 Windows 命令行过长(os error 206)无法运行,以rustfmt --edition 2021 --check检查本 PR 两文件干净;hook 同样被 206 卡死,提交时走了其「cargo 不在 PATH 则跳过」分支——如实记录。Owed
2>&1合流时 stdout/stderr 的交错顺序(GNU 逐名交错)仍是仓级缓冲输出限制(fix(builtins): report each missing declare -p name once, in operand order #3378 Owed 2),本 PR 未涉及。Fixes #3529