Repository navigation
fix: exec-failure diagnostic reports the PATH-joined relative form (Refs #3827) - #3831
Merged
caomengxuan666 merged 2 commits intoNov 17, 2026
Merged
Conversation
…efs #3827) GNU shell_execve (execute_cmd.c:6126-6159) reports the execve failure against the filename it handed to execve: for a PATH shape that is the walk's as-written join (findcmd.c sh_makepath). A relative PATH entry therefore reports `sub/mycmd: Permission denied` (rc 126), never the session-cwd-anchored absolute path. report_external_spawn_error (external_inner.rs) and member_spawn_failure (pipeline_exec.rs) both printed the anchored `program` for slash-free words; the stale comment in report_external_spawn_error misread the rubash#231 precedent ("full candidate path" is the join, and the absolute form appears only when the PATH element itself is absolute). Both sites now derive the report name through the shared execve-filename funnel spawn_exec_name (rubash#2378/#2442), which declines (None) when the resolution did not itself produce the join (a hash-table hit, an empty-element bare name), keeping the anchored display for those shapes. The `exec` builtin keeps its own full_pathname form (builtins/exec.rs), per GNU's deliberate rebind. Regression pins: tests/issue3827_exec_failure_diagnostic_relative_path.rs (9 cells: rel-sub, rel-dot, rel-dotdot, empty-element, abs-entry control, direct-slash control, missing-command control, rel-sub-exec control, pipeline member).
Member
Author
|
PR #3831 第1轮 — 建议:FAIL(单点:新增测试文件 unused import 触发 -D warnings;机制与钉本身已验证无误) 机制核查:
腿(逐项给数字与名字;unix 腿在 WSL Rust 1.99.0 / Linux 上跑,Windows 侧该 stem 因 cfg(unix) 编译为空):
F 点(建议 FAIL 时逐条):
续作记录:无(只审未改) 未跑/VOID 的腿:无 |
Member
Author
|
PR #3831 第2轮 — 建议:PASS(F1 已修,新 head 全腿复核通过) 机制核查(同第1轮结论,未变):
腿(逐项给数字与名字):
F 点回应:
续作记录:
未跑/VOID 的腿:无 |
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.
根因
经相对 PATH 条目找到的命令,exec 失败时 rubash 诊断印会话 cwd 锚定的绝对路径(
<cwd>/sub/mycmd: Permission denied);GNU 印 PATH 拼接形(sub/mycmd: Permission denied),rc 均为 126。GNU shell_execve(execute_cmd.c:6126-6159)对 execve 失败报告它交给 execve 的那个文件名;对 PATH 形态,那就是查找构建的 as-written 拼接(findcmd.c
sh_makepath)。rubash 的report_external_spawn_error(external_inner.rs)与member_spawn_failure(pipeline_exec.rs)对无斜杠词一律印锚定的program;report_external_spawn_error内的旧注释还误读了 rubash#231 前例——GNU 的 "full candidate path" 就是这个拼接,绝对形只在 PATH 条目本身绝对时出现。GNU 锚点
search_for_command;findcmd.c:580-600find_in_path_element(可执行返回full_path=sh_makepath拼接;不可执行的已存在文件记为file_to_lose_on = savestring(full_path))find_user_command_in_path(两者皆为拼接形)shell_execve(以同一command字符串报file_error/internal_error)absolute_program(仅/开头为绝对)get_next_path_element(空 PATH 条目归一为.,故拼接为./name)修复
两处皆经共享的 execve 文件名漏斗
spawn_exec_name(rubash#2378/#2442)取报告名;它在解析本身未产出该拼接时返回 None(哈希表命中、无斜杠的空条目拼接),此时保留锚定显示。exec内建保持自己的full_pathname形(builtins/exec.rs),因 GNU 对exec有意先重绑定。src/executor/external_inner.rs:report_external_spawn_error(简单命令路径)+ 修正误读 [linux] Exec-failure diagnostics use 'rubash:' prefix and drop the '/usr/bin/bash: line N:' context GNU prints #231 的旧注释src/executor/pipeline_exec.rs:member_spawn_failure(管道成员路径)+ 注释措辞回归钉
tests/issue3827_exec_failure_diagnostic_relative_path.rs(9 格,unix-only):相对sub、.、../sib、空 PATH 条目(→./mycmd)、绝对条目对照、直接斜杠对照、缺失命令对照(127)、相对条目可执行对照、管道成员。本 PR 删除了什么
无。仅修正两处诊断的报告名与相关注释,并新增回归钉;未删除任何功能、测试或公开面。
UNVERIFIED-BY-CAPTAIN