Repository navigation
fix(describe): report the PATH file for env off Windows (Refs #2642) - #3451
Merged
Merged
Conversation
GNU describe_command (builtins/type.def:211) has no env builtin — env is a coreutils program — so on unix the describe faces must report the PATH file (command -v env -> /usr/bin/env, command -V env -> 'env is /usr/bin/env', type -t env -> file). This nail currently fails on master 3ef22b8, where the faces report the bare name / 'env is a shell builtin' because the builtin-table row short-circuits the PATH branch (#2514 fixed the emulation-registered names but missed this row). Refs #2642
#2514 residual: #2514 gated the emulation-registry disclosure to the Windows face, but env is not a registry claim — it is a builtin-table row (BuiltinRow { name: "env", handler: H::Env }), so the describe faces short-circuited on is_enabled_shell_builtin_name("env") and never reached the PATH branch: command -v env printed the bare name, command -V env printed 'env is a shell builtin'. GNU anchor: bash 5.3 has no env builtin (no builtins/env.def; env is coreutils), so describe_command (builtins/type.def:211, called by command at builtins/command.def:113 and by type at builtins/type.def:180) resolves it as a disk file: command -v env -> /usr/bin/env, command -V env -> 'env is /usr/bin/env', type -t env -> file. Fix, describe-only (the #2514 shape): - builtin_table.rs gains the single canonical set NON_GNU_BUILTIN_NAMES = &["env"] (table rows GNU does not ship; currently only env, the Windows emulation face for a platform with no /usr/bin/env). compgen -A command's #2538 filter now references it (behavior unchanged). - lookup_paths.rs::is_enabled_shell_builtin_name returns false for that set off Windows. Codegraph-verified, the predicate has exactly two callers in the tree, both describe faces (describe_name_with_io / describe_name_all_with_io), so the gate is exactly describe-only; dispatch, enable -n env, compgen -b, builtin env and help env keep the unified projection. - docs/builtins.md prose synced (§1 disclosure, §2 list note, §3 hybrid-form paragraph). Refs #2642
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿(逐项给数字与名字):
F 点:无 续作记录:无 未跑/VOID 的腿:
|
caomengxuan666
marked this pull request as ready for review
November 15, 2026 02:05
This was referenced Nov 15, 2026
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.
根因
#2514 的残差。#2514 把 describe 面的仿真注册表披露门限到 Windows 面,但
env不是仿真注册表 claim——它是 builtin 表的一行(src/executor/builtin_table.rs的BuiltinRow { name: "env", handler: H::Env }),所以 describe 面在is_enabled_shell_builtin_name("env")处短路,command -v env印裸名、command -V env印env is a shell builtin,从未走到 PATH 分支。GNU 锚点
GNU bash 5.3 没有
envbuiltin(无 builtins/env.def,env 是 coreutils 程序):describe_command(builtins/type.def:211,command在 builtins/command.def:113 调用、type在 builtins/type.def:180 调用)按 alias → keyword → posix special builtin → function → builtin → 磁盘文件顺序解析,env落到磁盘文件分支:command -v env→/usr/bin/env,command -V env→env is /usr/bin/env,type -t env→file。修法(本 PR 第二提交)
builtin_table.rs新增单一典范集NON_GNU_BUILTIN_NAMES = &["env"](GNU 表没有的行,目前仅env);compgen -A command的 [completion] compgen -A command 把 env 列为内建候选,GNU 无此内建(#1795 残面) #2538 过滤改引该集(行为不变)。lookup_paths.rs::is_enabled_shell_builtin_name:非 Windows 上该集名字不视为 describe builtin。codegraph 核实该谓词全仓仅两个调用者,都是 describe 面(describe_name_with_io/describe_name_all_with_io),所以门控恰为 describe-only;执行路由、enable -n env、compgen -b、builtin env、help env均不动。docs/builtins.md散文同步(§1 披露段、§2 清单说明、§3 混合形态段)。本 PR 删除了什么
未删除任何产品行为或公开面:仅 describe 面在非 Windows 上对
env的回答由 builtin 形改为 PATH 文件形;删除的是一处已钉死的错误期望(issue2036_introspection_env_reports_builtin翻转为文件答案,文件本身为 unix-only;Windows 面行为由issue2036_s2_introspection_windows另钉,不动)。验证(UNVERIFIED-BY-CAPTAIN)
tests/issue2642_command_v_env_regressions.rs(5 测试:fakebin 精确路径形、ambient PATH 与 GNU 同形、空 PATH 未找到形、执行面仍进程内形、enable -n env仍可禁用形)。RUSTFLAGS="-D warnings"check、hygiene + fmt。Refs #2642