Skip to content

Refs #2661 #2696 #2717 #2755 - #3120

Merged
caomengxuan666 merged 10 commits into
masterfrom
fix/X2-wave1
Nov 9, 2026
Merged

caomengxuan666 merged 10 commits into
masterfrom
fix/X2-wave1

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

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 锚点)

验证数字(车道自验:工具托管前台跑,逐茎核 test result 行在位)

残余(已立单,不在本 PR 面)

…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.
…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
caomengxuan666 marked this pull request as ready for review November 9, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant