Skip to content

Startup PWD repair: stop rewriting literal backslashes on Unix - #3594

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3570-startup-pwd-backslash
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3570-startup-pwd-backslash

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Refs #3570

On Unix a backslash is an ordinary filename byte (general.h:264-270
ABSPATH) and GNU set_pwd (variables.c:907) binds the
get_working_directory spelling verbatim when the inherited PWD is
invalid. The unconditional \→/ replace turned a physical cwd named
cwd\backslash into the nonexistent cwd/backslash, so $PWD pointed
at a phantom directory and relative lookups could fail. The rewrite is
now Windows-only, next to the already-gated TMPDIR/HOME normalization.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Refs #3570

On Unix a backslash is an ordinary filename byte (general.h:264-270
ABSPATH) and GNU set_pwd (variables.c:907) binds the
get_working_directory spelling verbatim when the inherited PWD is
invalid. The unconditional `\`→`/` replace turned a physical cwd named
`cwd\backslash` into the nonexistent `cwd/backslash`, so $PWD pointed
at a phantom directory and relative lookups could fail. The rewrite is
now Windows-only, next to the already-gated TMPDIR/HOME normalization.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3594 第1轮 — 建议:PASS
head: c43060e base(merge-base): 96802ca 文件: 2 个 +42/-1
关联 issue: #3570(状态:open,我核过的时间:2026-11-15 本机)

机制核查:

  • src/executor/init.rs:1653 的无条件 \→/ replace 改为 #[cfg(windows)]——Windows 面逐字节不变(反斜杠是分隔符,replace 正确保留),Unix 面改绑 cwd.to_string_lossy() 原样拼写。GNU 依据:variables.c:907 set_pwd() 绑 get_working_directory 原样拼写;general.h:264-270 ABSPATH——Unix 反斜杠是普通文件名字节。与 issue 指认的 owner 行精确对应。
  • 无关改动:无;非桥接层,是平台语义分叉。

#3570 形状覆盖核对:

腿(逐项):

  • 钉自跑:本机 cargo test --test issue3570_startup_pwd_backslash --locked → 0 tests(#![cfg(unix)],Windows 上为空桩)——本腿在 Windows VOID;Unix 执行证据为 0(见 CI 项)。
  • fail-first:同上 VOID(钉在 base 也是 0 tests);语义经 issue oracle 证据复核(GNU PWD=<...cwd\backslash> vs rubash base cwd/backslash)。
  • lib 双边:无产品面差异(Windows 代码路径不变);CI lib 红名 {issue2875} 基线。
  • 卫生:rustfmt 直检 init.rs 有 diff 但位于 line 109 windows import 块——与 path.rs 同型基线 rustfmt 版本漂移,非本 PR hunk(~1650 行)。
  • CI:三红任务(goldens/Rust tests/macOS),既往同批均 = {issue2875} 基线。钉在 CI 上无执行:它跑在普查步(ci-run-pin-stems.sh)覆盖内,而普查步因 lib 步 issue2875 先红不可达(同 ci: run every integration stem in the census, with recorded exclusions (Refs unixwin/niubash#955) #3600 报告的可达性问题)。
  • GNU 对照:issue 自带 oracle(Bash 5.3.20/vendored 9c465866):GNU PWD=</tmp/.../cwd\backslash> vs master cwd/backslash——形状与本修复一致;本机无法再跑 Unix rubash。

F 点:无。
续作记录:无。
未跑/VOID 的腿:钉自跑+fail-first(#![cfg(unix)] 在 Windows 恒 0 tests;CI 普查步不可达——Unix 执行证据缺,列为 VOID 供队长知悉;机制经源码+issue oracle 核对无虞)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【队长终裁】PENDING(缺腿)

核过审计报告(6886635499)+ CI 全表。机制经源码 + issue oracle 核对无虞(GNU variables.c:907 set_pwd 绑原样拼写;Unix 反斜杠是普通文件名字节;#[cfg(windows)] 分叉使 Windows 面逐字节不变;#3570 单一形状已覆)。但判词由 PASS 降为 PENDING,理由一条:钉是 #![cfg(unix)],Windows 上 0 tests(本地 VOID),而 CI 普查步因 lib 步 issue2875 先红不可达(见 #3656)——本钉在任何地方都未执行过,合入会落下一枚未执行的回归钉。PENDING 直到钉在 Unix 腿上执行通过(stem:issue3570_startup_pwd_backslash)。执行窗口:本机内存恢复(Mem≥1.5G)或 box 唤醒后跑 Linux 腿。#3570 保持 OPEN。

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