Repository navigation
feat(builtins): pwd -W prints the win32 spelling of the physical cwd (Refs unixwin/niubash#993 §6) - #3716
Merged
Conversation
…(Refs unixwin/niubash#993 §6) Git Bash carries the MSYS extension `pwd -W`; migrated scripts use it for `docker -v`, `javaw -classpath` and other Windows-tool handoffs. rubash rejected it (`pwd: -W: invalid option`, `usage: pwd [-LP]`). Git Bash 5.3.15 semantics, probed on this machine: - `pwd -W` prints the win32 spelling of the PHYSICAL cwd — `cd` into a junction and `-W` prints the resolved target, exactly like `-P` (`/c/tmp/jlink` -> `C:/tmp/real`, verified). - `-W` shares the L/P option slot, last wins: `-LW`/`-PW` -> win32, `-WL`/`-WP` -> POSIX. - usage/help render `pwd [-LPW]` and document `-W` ("print the Win32 value of the physical directory"); `pwd --help` output matches. Implementation: Mode::Win32 in builtins/pwd.rs runs the same physical resolution as -P (junction resolution, the canonicalize failure gate and its resetpwd poisoning, the // PWD preservation), then renders the resolved POSIX display through shell_path_to_windows — the one shell-path->win32 funnel every subsystem uses — forward-slashed like Git Bash (`C:/tmp`, `//srv/share`). Under the __RUBASH_PHYSICAL_PWD bridge (`cd /`) the bridged name maps to the configured shell root's native path — the niubash equivalent of Git Bash's install root. The `pwd [-LP]` -> `[-LPW]` usage/help wording intentionally diverges from recorded upstream GNU goldens to match the MSYS persona (the same divergence class as BASH_VERSINFO's -msys triplet); the checked- in upstream-rights baseline is left GNU-true. Verification: Git Bash probe matrix above reproduced byte-identically via rubash.exe -c; new tests/niubash993_pwd_w 4/4; lib pwd/cd/path tests 10/10; issue2753/2791 pins updated to the -LPW usage and pass; the five command_chaining::part_021 pwd/export failures reproduce identically on clean master (PWD-verbatim adoption removed by rubash#2797; argv0-derived `bash:` prefix), unrelated. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This was referenced Nov 18, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 19, 2026
## 根因 `issue3185_help_listing_column_major` 在现尖恒红(队长 census:0 PASS / 1 FAIL),红在四张期望格的 `pwd` 行(第 12 行)。`HELP_ENTRIES` 里的表项现在是 `pwd [-LPW]`(src/builtins/help.rs:608),而四张期望格生成于表项还是 `[-LP]` 之时,未随 `-W` 落地而重生成。非 #3185 本身复发。 ## 抉择:保留 `[-LPW]`(#3918 方案 2) - `-W` 是真实功能:`src/builtins/pwd.rs` Mode::Win32(#3716,niubash#993 §6 的 MSYS conv-to-win32 显示形),有专属茎 tests/niubash993_pwd_w.rs。 - 表项之外,`help pwd` 短档(src/builtins/help_texts.rs:1332)、usage 行(src/builtins/pwd.rs:123)与 issue2753/2791 钉早已是 `[-LPW]`;把表项改回 `[-LP]` 会让裸 `help` 与 `help pwd`、`pwd -x` 三处互不一致。 - #3716 提交正文已明言:usage/help 渲染 `pwd [-LPW]` 是有意偏离 GNU goldens 的 MSYS persona 取舍。 ## GNU 锚点 - GNU 5.3.20 的 $SHORT_DOC 是 `pwd [-LP]`(builtins/cd.def:436、builtins/builtins.c:68)。 - oracle 实测(~/workspace/rubash-audit/build-gnu/bash-5.3/bash,5.3.20):`LC_ALL=C COLUMNS=80/120 help` 的 pwd 行均为 `pwd [-LP]`;`help pwd` 首行 `pwd: pwd [-LP]`。 - 故 `[-LPW]` 是有意的 rubash 扩展,与本文件头注已载明的 `env` 额外条目同类。 ## 改动 仅 tests/issue3185_help_listing_column_major.rs(+9/−4):四张期望格的 pwd 行 `[-LP]` → `[-LPW]`,另加 5 行头注说明取舍与生成器出处。未碰 #3919(#3330)的文件表(src/script_driver.rs、pty 宽度探针、issue3330 测试)。 ## 生成与验证 - 生成器 ~/workspace/fix-3918/gen_expected_3918.py(由 #3330 的 gen_expected.py 改编,REPO 指向本车道树):渲染器先对 GNU 5.3.20 oracle 自身的 77 条输出(rubash 表去 `env`、pwd 回 `[-LP]`)在 COLUMNS=80 与 120 下逐字节校验通过;再对落盘四格校验——除 pwd 行外零差异;重生成后四格与现表逐行一致(UTF8_80 第 21 行为 wdispcolumn 边界行,按原样保留)。 - fail-first(渲染器层):修前渲染器输出与落盘四格恰差 pwd 行一处;修后零差。另有队长 census 的茎现红佐证。 ## 验证状态:UNVERIFIED-BY-CAPTAIN **本车道未跑任何二进制腿**:新服务器 SSH 三次均 banner 超时(经 egress 代理 198.19.0.1:3128,23:5x 三次);X299 反向隧道断;Simular box 钱包为空;本 VM 本地构建禁。base/fix 两份 tarball 已备在 ~/workspace/fix-3918/(rubash-3918-base.tgz / rubash-3918-fixed.tgz),待队长在恢复的路线上补跑:基底茎 fail-first + 修后茎 6/6 + lib 对齐。 ## 本 PR 删除了什么 无。仅重生成四张期望格的 pwd 行与 5 行头注;无产品代码改动,无文件删除。 ## 队长复核(头 bb3e080) - 服务器腿(队长跑):fixed 树自带钉 **6/6 PASS**,base(47a24b28)同钉 **0/6 FAIL**——fail-first 成立(基线期望网格缺 W)。 - 头 CI census 72:自带钉 6/6 绿,相对尖集新增仅 issue1902 抖动格;goldens 仅基线二名;CLI/Rust/cross/Windows/shell/ledger/niu 全绿;macOS 腿为 cancelled 且 steps 为空(未运行,非产品红,日志 blob 已过期、由 jobs API 核实)。 - 纯测试对齐(四格 pwd 期望 [-LP]→[-LPW],与 niu #993 §6 的既定扩展一致);与现尖零交集已核(merge-base 以来无人动 issue3185 钉文件),免 update-branch。Refs-only,合后手关 #3918;#3924(pwd 用法行钉间矛盾)随之解闸。
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.
Summary
pwd -W(the MSYS/Git Bash extension used by migrated scripts fordocker -v,javaw -classpath, etc.) was rejected:pwd: -W: invalid option,usage: pwd [-LP].Mode::Win32runs the same physical resolution as-P(junction traversal, canonicalize failure + resetpwd poisoning,//PWD preservation) and renders the resolved POSIX display throughshell_path_to_windows— the one shell-path->win32 funnel — forward-slashed like Git Bash.-Wshares the L/P option slot (last wins), usage/help now readpwd [-LPW]with the-Wdoc line, byte-matching Git Bash'spwd --help.cd /maps to the configured shell root's native path (the niubash equivalent of Git Bash'sC:/Program Files/Git).Probes (Git Bash 5.3.15, this machine)
cd /c/tmp->pwd -WC:/tmp;cd /c->C:/jlink -> real:pwd/c/tmp/jlink,pwd -WC:/tmp/real,pwd -P/c/tmp/real— physical, not logical-LW/-PW->C:/tmp;-WL/-WP->/c/tmp;pwd -x->usage: pwd [-LPW], status 2All reproduced byte-identically.
Intentional persona divergence
pwd [-LP]->[-LPW]in usage/help text matches Git Bash, diverging from recorded upstream GNU output — same class as BASH_VERSINFO's-msystriplet.tests/gnu-compat/upstream-rights/builtins.rightis left GNU-true.Verification
tests/niubash993_pwd_w.rs: 4/4 (win32 spelling, option-slot ordering,[-LPW]usage, bridged-root -> shell root).command_chaining::part_021failures reproduce identically on clean master (rubash#2797 PWD adoption + argv0 prefix), unrelated.Generated with Devin