Repository navigation
fix(exec): rebind the exec target with GNU full_pathname (Refs #3316) - #3564
Conversation
builtins/exec.def:172 rebinds the target word with full_pathname (general.c:931-943): an absolute word verbatim, otherwise sh_makepath(NULL, word, MP_DOCWD|MP_RMDOT) -- the cwd, a '/', and the word with exactly one leading "./" removed. The exec builtin instead used the session-anchored resolved program (cwd join keeping "./") as the execve filename and script $0, and its failure reports ran a different, over-eager canonicalization (dropping every "." and ".."). One full_pathname helper now produces the execve filename (so a #! script's $0), the ENOEXEC re-entry's $0, and every exec failure report name, over the shared spawn funnel's word (path::spawn_exec_name). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Enumerate workspace target roots with cargo metadata and bound each rustfmt argv below the Windows command-line limit. Fail closed if required tooling is missing. Include the two pre-existing rustfmt wrapping corrections so the gate passes without bypasses. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Reject missing workspace member packages, empty target sets, and targets without source paths before launching any rustfmt batch. Malformed metadata must not silently reduce the gate's coverage and still report success. Preserve edition fallback, target deduplication, CLI and bounded batching. All 15 checker tests pass; the real gate checks 1486 targets in 10 batches. Refs #3569. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Bring the formatting-gate feature history into this draft feature branch so follow-up commits run the normal Windows pre-commit check without the legacy command-line overflow. This does not merge either PR into master. Refs #3569; its review and landing remain independent. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
GNU builtins/exec.def:151/172 exec_builtin rebinds the target through general.c:931 full_pathname. general.h:264-270 ABSPATH recognizes only a leading slash on Unix, and lib/sh/makepath.c:66 sh_makepath copies the cwd and remaining word unchanged after stripping one leading ./. Restrict backslash folding and DOS-drive recognition to Windows. Unix backslashes in filenames and cwd remain ordinary bytes; D:/ is relative. Preserve the original Windows behavior and the exec target owner. Match the test fixture's Unix PWD to Command::current_dir, as in a real parent shell. The distinct pre-existing stale-PWD repair defect is #3570. New Linux pins: 4 pass/3 fail before, 7 pass after. Adjacent exec/argv0/ name diagnostics: 35 pass. Existing Windows pin: 1 pass. Full formatting gate: 1487 targets in 11 batches. Refs #3316, #3564. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Full-Pathname Re-Review: Unix Regression FixedPushed
The fix gates only the Win32 spelling rules to Windows. Unix word/cwd GNU ownership read before editing: exec.def:151/172 Verification:
The Unix test fixture now exports PWD matching Command::current_dir, as a The draft feature history adopts formatting-gate prerequisite #3569 so Complete raw logs and script-file probes: |
|
【WIN-AGENT-AUDIT】s10 lane — 建议:PENDING(CONFLICTING,跳过不合) head: adcbd99 base(merge-base): 8b48c16 文件: 8 个 +884/-99 处置:不合并。
按 S 波口径(DIRTY/CONFLICTING → 跳过不合,报告),本轮不做冲突消解、不推进 head。 审计中已发现、需在消解冲突时一并处理的两点(供队长/续作参考,非本轮判词):
腿:本轮全部未跑(按 CONFLICTING 跳过规则),不记为通过。 未跑/VOID 的腿:
|
|
【WIN-AGENT-AUDIT】 head: adcbd99(gh 实时,未变) mergeable=CONFLICTING/DIRTY 要点:
未跑/VOID 的腿:无(纯裁决关联评论,未动代码)。 |
# Conflicts: # scripts/git-hooks/pre-commit # src/builtins/exec.rs
Refs #3316
修了什么
exec ./s.sh的脚本内$0留有/./($PWD/./s.sh),GNU 为$PWD/s.sh。根因:exec 内建把 会话 cwd 锚定后的 resolved program(
cwd.join("./s.sh"),保留./)直接当 execve filename / ENOEXEC 重入的$0;而它的失败报告名又走了另一套过度规范化(删掉所有.与..分量)。两条都不是 GNU 的full_pathname。修法(
src/builtins/exec.rs):一个full_pathname()按 GNU 逐字实现——绝对词原样;否则cwd + "/" + 词,且只去掉一个前导./(MP_RMDOT),其余分量(././s、a/./s、a/../s、.//s)一律保留。它的输入词由exec_target_word()取自共享 spawn 漏斗path::spawn_exec_name(带斜杠的词=原样;PATH 搜索=as-written<elem>/<name>拼接)。这一个字符串同时用作:#!脚本由内核把它交给解释器当$0)——改走external_command_for_named_program_with_exec_name(..., Some(filename));$0(shell_wrapped_command的 zero word);exec_report_name、缺失路径报告)。src/executor/path.rs只改注释(exec 不再是"漏斗例外",而是"漏斗词再经 full_pathname")。另:
tests/d11_pipeline_squote_carrier_regressions.rs仅 rustfmt 重排(master 上该文件未格式化,cargo fmt --check在 master 即红;与 #3547/#3549 等同款 diff 逐字节一致)。删了什么
full_pathname_word()(把所有.分量删光且在 unix 上会丢根/的旧实现)与exec_report_name里的./..文本规范化;缺失路径报告里的.replace("/./", "/")。GNU 依据
builtins/exec.def:151取目标词(absolute_program (args[0]) ? args[0] : search_for_command (args[0], 1))builtins/exec.def:172com2 = full_pathname (command),exec.def:231交shell_execvegeneral.c:931-943 full_pathname():绝对词原样(937-938),否则sh_makepath (NULL, file, MP_DOCWD|MP_RMDOT)(940)lib/sh/makepath.c sh_makepath():MP_RMDOT仅在dir[0]=='.' && dir[1]=='/'时跳过 2 字节;拼接时 cwd 末尾非/才补/execute_cmd.c:6253ENOEXEC 重入args[1] = command(新$0)GNU 5.3.20 实测(WSL
/usr/local/bin/bash,脚本文件,$PWD折成D):exec ./s.sh→D/s.sh,exec ././s.sh→D/./s.sh,exec .//s.sh→D//s.sh,exec sub/../s.sh→D/sub/../s.sh,PATH=.:$PATH exec s.sh→D/s.sh,PATH=./sub/:$PATH exec t.sh→D/sub/t.sh;缺失:exec sub/./nope→D/sub/./nope: No such file or directory。修后 Linux 构建 17 形全部逐字节一致。验证(逐 stem 报数)
tests/issue3316_exec_full_pathname.rscargo build -j 4干净(Windows + Linux);cargo fmt --check干净(WSL 全树;Windows rustfmt 1.10 对改动文件--check干净)Owed
PATH=.:$PATH; exec s.sh)仍给$PWD/./s.sh:非 unix 的spawn_exec_name返回 None,Windows 查找无 as-written 拼接,回落到 resolved program。需给 Windows PATH walk 补 as-written 记录,范围超出本 PR —— 故用Refs不用Fixes。C:/...形(既有行为,未动)。exec '~/x'(引号内字面~)的 full_pathname 波浪号展开分支(general.c:935)未实现,未测。