Repository navigation
Refs #2661 #2696 #2717 #2755 - #3120
Merged
Merged
Conversation
…Refs #2661) GNU builtins/exec.def:163-166 probes file_isdir(args[0]) on the operand as written once the search fails, so `exec .` and `exec somedir` report "cannot execute: Is a directory" with EX_NOEXEC instead of "not found". The PATH walk discards directories (findcmd.c FS_NODIRS), so the probe must run on the operand itself, anchored at the session cwd, ahead of the slash-operand branch.
…#2696) GNU's walk builds ONE string - the as-written <elem>/<name> join (findcmd.c sh_makepath) - and that string is what phash_insert records, what hash/type print, and what shell_execve executes verbatim. Rubash recorded the anchored absolute display instead, so a relative element (PATH=./rel1:...) was absolutized (with /./ residue) and a post-cd re-run re-walked PATH and missed. - path::recorded_resolution_spelling prefers the as-written join when anchoring it at the session cwd lands on exactly the resolved program (the exec_name_for_program test, rubash#2378); all three record sites use it (plain dispatch, emulated stand-ins, tput). The command -p standard-path record keeps the anchored display - its walk never consulted the env PATH. - record_command_resolution now syncs the lookup mirror with the recorded spelling (record_standard_path_resolution already did), so the next lookup is a phash_search hit serving the recorded string instead of a fresh walk. - spawn_error_diagnostic probes a relative program anchored at the session cwd - the directory the child was born in - so a recorded target that no longer exists there classifies as ENOENT (127), not as a bad interpreter read from the wrong directory. This also repairs the same misclassification for relative hash -p pathnames.
GNU describe_command (builtins/type.def) reports an absolute_program name only when findcmd.c file_status grants FS_EXECABLE - an existing, executable, non-directory file - and reports it verbatim. Rubash reported ./seed.txt (mode 644), absolute equivalents, and even /nonexistent/x as found commands: command_path short-circuited absolute names unconditionally and let relative slash names fall through to the execution walk, whose file_to_lose_on semantics (is_file only) are correct for EXECUTION but wrong for describe. - path::slash_name_is_describable is the one qualification probe (anchored at the session cwd, E400-folded, like the walk's own slash branch); find_user_command itself is untouched, so executing a non-executable PATH hit still earns EACCES 126. - command_path / command_paths gate slash-bearing names on it and skip the PATH walk/enumeration for them entirely. - The command builtin's fallback describe applies the same gate instead of printing the anchored lose-on path.
This was referenced Nov 8, 2026
…2755) GNU reports the unresolvable-#! refusal through sys_error (execute_cmd.c:6184), the one reporter built on error_prolog(0): the prolog is get_name_for_error alone, never a line segment. Rubash printed it through the error_prolog(1) prefix, producing 'case.sh: line 1: ...: bad interpreter' where GNU prints 'case.sh: ./badinterp: ...: bad interpreter'. - Executor::sys_error_prefix joins error_prefix in public_accessors: interactive basename or error_report_name, no line segment in any context. - spawn_error_diagnostic also returns its prolog family; only the bad-interpreter arm is sys_error - the sibling classifications keep error_prolog(1) and their line segment. - report_external_spawn_error picks the prefix by family and reports the filename shell_execve handed to execve: the typed word itself for a slash-bearing name (findcmd.c:385-387), the resolved program otherwise (rubash#231 unchanged). - spawn_async_direct builds its pre-fork ENOENT line with the same family rule.
caomengxuan666
marked this pull request as ready for review
November 9, 2026 05:41
This was referenced Nov 9, 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.
UNVERIFIED-BY-CAPTAIN — 180 单令第一波 · 组 X2(四单同 PR,逐单钉分开提交)
覆盖单
Refs #2661
Refs #2696
Refs #2717
Refs #2755
本 PR 删除了什么
无文件删除、无 API 删除。修法提交(钉头
4dfce610→d05e6c32)共 11 文件 +289/−65,删除的均为被替换的旧逻辑行:hash 记录点的锚定绝对化拼写构造、describe 层对斜杠名的无条件Some返回、spawn 诊断统一走带行段 prolog 的旧路径。全 PR(基底88047f50→d05e6c32)12 文件 +752/−45(四个钉文件为新增)。逐单(根因 + GNU 锚点)
exec未找到分支只在含斜杠子分支探目录,无斜杠目录操作数(.、cwd 下目录名)被 PATH walk 按 FS_NODIRS 丢弃后一律报 not found / 127。GNUbuiltins/exec.def:153-172:搜索失败后以file_isdir(args[0])按操作数原文分类 →cannot execute: Is a directory/ 126。修法:折叠 E400 后、斜杠分支前按操作数原文(锚定会话 cwd)探 is_dir。find_user_command的锚定绝对路径记入 hash 表,且record_command_resolution不同步查找镜像——相对 PATH 元素(./rel1)被绝对化(带/./残留),cd 后执行重新 walk 落空。GNUfindcmd.c:walk 只构造 as-written join 一串,phash_insert记录它、shell_execve逐字执行它。修法:新path::recorded_resolution_spelling(as-written join)+ 记录后同步查找镜像 +spawn_error_diagnostic探针锚定会话 cwd。command -vreports non-executable slash-named files (no file_status qualification) and absolutizes them #2717:describe 层对斜杠名无 file_status 资格判定——command_path_with_bridge对绝对名无条件返回 Some(/nonexistent/x也报找到),644 文件被报为找到。GNUbuiltins/type.defdescribe_command +findcmd.cfile_status 的 FS_EXECABLE(存在 + 可执行 + 非目录)。修法:describe 层单一资格探针path::slash_name_is_describable门控;执行 walk 不动。line 1:segment GNU omits #2755:spawn 失败诊断统一走error_prolog(1)族(带line N:段);GNU bad-interpreter 走 sys_error(execute_cmd.c:6184,建在error_prolog(0)上,永不带行段),报告名为交给 execve 的文件名原词。修法:Executor::sys_error_prefix+spawn_error_diagnostic增返 prolog 族标记 + 斜杠词报告名用折叠后原词。验证数字(车道自验:工具托管前台跑,逐茎核
test result行在位)88047f50+ 钉):[upstream] exec: executing a directory reports "not found" / exit 127 instead of "cannot execute: Is a directory" / 126 #2661 茎 3 过/2 红、[A2-13] Hash table stores absolutized path; type prints it instead of the as-found relative spelling #2696 茎 1 过/1 红、[B2-F05]command -vreports non-executable slash-named files (no file_status qualification) and absolutizes them #2717 茎 1 过/2 红、[B6-R18] Bad-interpreter exec diagnostic carries aline 1:segment GNU omits #2755 茎 1 过/2 红——红恰缺陷格,守卫格全绿。d05e6c32):四茎 13/13 全绿(5/2/3/3)。issue1038一格红与基底同名同形(既存,非本 PR 引入);issue2925批量跑一格红,基底 4/4 绿且头单茎复跑 4/4 绿(时序 flake)。RUSTFLAGS="-D warnings":头 lib+bins rc=0、本 PR 四钉目标 rc=0;--all-targets在基底与头上同因他车道钉文件的既存 warning 失败(issue2702dead-code /issue2500unused-variables,均不在本 PR 文件集内)。cargo fmt --checkrc=0。残余(已立单,不在本 PR 面)
exec内建面的 bad interpreter 分类未做(在 exec.rs 的 run_external_exec 报告线)。