Repository navigation
fix(executor): expand tilde-leading PATH elements at lookup time (Refs #3826) - #3832
Merged
Merged
Conversation
…3826) GNU findcmd.c:544 expands a '~'-leading PATH element at lookup time; rubash joins the element verbatim, so a '~/bin' entry never matches. 11 cells: run / command -v / hash / hash -t / export / variable-assignment / type (defect), PATH-assignment-stays-literal / absolute-entry / bare-tilde (controls), set -o posix (guard). UNVERIFIED-BY-CAPTAIN
…#3826) GNU findcmd.c:544 expands a '~'-leading PATH element inside the walk (xpath = (posixly_correct == 0 && *path == '~') ? bash_tilde_expand (path, 0) : path); rubash joined the element verbatim, so '~/bin' never matched. Add expand_path_element_tilde (reusing tilde_expand::expand_tilde_segment: ~/... via $HOME, ~+/~-/~N via the dirstack, ~user via getpwnam, unresolvable user verbatim; skipped in POSIX mode) and apply it at the four join points: the unix walk, path_scan_scaffold (Windows walk), command_paths (-a enumeration) and memoized_miss_still_absent (the unix memoized-miss probe, which must agree with the walk). hash follows via find_user_command, so no hash change is needed. UNVERIFIED-BY-CAPTAIN
String::from_utf8_lossy returns Cow<str>; .replace() on it already yields an owned String, so the trailing .into_owned() is both redundant and invalid (String has no into_owned). The stem failed to compile on X299 (E0599, both base and fixed legs) — this commit repairs the pins only, no product change. UNVERIFIED-BY-CAPTAIN
Member
Author
|
PR #3832 第1轮 — 建议:PASS(附相邻残差,范围裁量见下) 机制核查:
腿(逐项给数字与名字):
F 点:无 续作记录:无(只审未改) 未跑/VOID 的腿:无 |
Member
Author
|
批次汇总(y1 波:#3832 / #3831 / #3830 / #3829)— 四个 PR 均已按全协议审毕,建议判词如下(均为建议,终审归队长):
阻塞项:无。四个 PR 的 CI 红任务均为已知基线(goldens {issue_753::case_9, upstream_suite_slice_snapshots} + census 基线红族),新钉 stem 在各自 census 中全过;未合入、未 approve、未改判,终审与合入顺序归队长。 |
caomengxuan666
marked this pull request as ready for review
November 17, 2026 04:52
This was referenced Nov 17, 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.
Refs #3826
根因
PATH 里的
~/...条目在查找时不展开:find_in_path_walk_unix(
src/executor/path.rs)与 Windows 走查(经path_scan_scaffold)把每个 PATH 条目原样与命令名拼接,
~/bin从不匹配磁盘路径,于是经该条目的运行、
command -v、hash、hash -t、type全部落空;
-a枚举(command_paths)与 memo 化未命中探针(
memoized_miss_still_absent)同样原样拼接。GNU 在查找时逐条目展开(
findcmd.c:544 find_in_path_element):xpath = (posixly_correct == 0 && *path == '~') ? bash_tilde_expand (path, 0) : path。赋值时不展开(
echo $PATH两侧皆字面量),POSIX 模式下不展开(
posixly_correct == 0门)。修法
新增
expand_path_element_tilde(src/executor/path.rs,复用赋值层
tilde_expand::expand_tilde_segment:~/~/...走 $HOME,~+/~-/~N走 dirstack,~user[/rest]走 getpwnam,不可解用户留原样;
set -o posix时留原样),在 4 个拼接点应用:unix 走查、
path_scan_scaffold(Windows 走查)、command_paths(
-a枚举)、memoized_miss_still_absent(unix 未命中探针)。hash走find_user_command,随走查一并修复,无需另改。钉
tests/issue3826_path_tilde_expansion.rs,11 格:运行 /command -v/hash/hash -t/ export / 变量赋值 /type(缺陷格,base 7 红);PATH 赋值仍字面量 / 绝对条目 /裸
~条目(对照格,两侧皆绿);set -o posix(守卫格,修法不得在 POSIX 模式下展开)。
GNU 锚点:
findcmd.c:544、lib/tilde/tilde.c:361-410(~user)。种子 R133-C(GNU 10/10,rubash 3/10)。
本 PR 删除了什么
无删除。仅新增 1 个测试文件 + 1 个 helper 与 4 处调用,
不删任何函数与测试。
验证(X299,腿已跑完)
已知基线 issue2084
RUSTFLAGS="-D warnings" cargo check --locked --lib --bins:Finished,无警告注:第一轮 stem 因钉文件
Cow::into_owned误用编译失败(E0599),已由提交
8434cf0f修钉(仅改钉,无产品改动);重跑后 fail-first与 11/11 均已拿到。第一轮腿脚本的 lib/warnings 步 rc 取的是
tail的值(恒 0),结论以逐格
test result行与 "Finished" 行为准。UNVERIFIED-BY-CAPTAIN