Skip to content

fix(realpath,readlink,pwd): one shell display spelling for path emitters (#1783) - #1784

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/niu993-path-display-spelling
Nov 16, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/niu993-path-display-spelling

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Closes #1783. Part of the niubash#993 Git-Bash drop-in compatibility audit (§7).

The three path emitters printed three different spellings for the same file — realpath gave C:\tmp\..., readlink -f gave C:/tmp/..., and the shell's pwd gave /c/tmp/.... Git Bash prints the /c/... form for all of them, and readlink prints d/f for a relative link target where we printed the stored Win32 d\f.

New winux_core::path::shell_display_path — the same display rule cygpath -u already implements (shell_tree_display mount name under a shell root, else the /c/ drive form) — applied at the emit boundary of realpath (all canon modes), readlink (canonicalize modes and verbatim targets), and pwd (physical and valid env PWD).

Test plan

  • winuxcmd-tests: 83/83 on realpath.*:readlink.*:pwd.*, including the new niu993_section7_all_emitters_share_display_spelling pin asserting all three print the identical path
  • cargo test -p winux-cmds: realpath:: readlink:: pwd:: canon:: green
  • Smoke: realpath d / readlink -f d/f / pwd all agree under /tmp mount and /c/ drive form

Generated with Devin

…ers (#1783)

The three emitters printed three spellings for the same file —
realpath's backslashed "C:\tmp\...", readlink -f's "C:/tmp/..." and the
shell pwd's "/c/tmp/..." (niubash#993 §7). Backslash output is unsafe
to feed into regex/glob consumers and `[[ $(realpath x) == /c/* ]]`
could never match.

winux-core gains shell_display_path: the canonical spelling of a native
path under a shell mount is its POSIX mount name (shell_tree_display),
everything else takes the /c/ drive form — the cygpath -u display rule,
which is exactly what Git Bash prints for all three commands.

- realpath (every canon mode) and readlink -f/-e/-m emit the display
  spelling instead of the raw native path; --relative-to/-base relative
  results pass through unchanged.
- readlink's verbatim target renders the display spelling too: the
  stored text is the Win32 form CreateSymbolicLinkW requires ("d\f",
  "C:\x") while Git Bash stores and reports "d/f", "/c/x".
- pwd emits the display spelling for both the physical path and a
  valid env PWD (a POSIX-spelled PWD passes through).

Test pins: normalize_path_text folds the /tmp and /var/tmp mounts plus
the /c/ drive form back to native; pwd's physical_spelling computes the
display form; one new end-to-end pin asserts realpath, readlink -f and
pwd print the identical path.
@caomengxuan666
caomengxuan666 merged commit 1c81457 into main Nov 16, 2026
15 of 17 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/niu993-path-display-spelling branch November 16, 2026 00:46
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.

Unify realpath/readlink -f/pwd on the shell display spelling (niubash#993 §7)

1 participant