Repository navigation
fix(realpath,readlink,pwd): one shell display spelling for path emitters (#1783) - #1784
Merged
Merged
Conversation
…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.
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
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 —
realpathgaveC:\tmp\...,readlink -fgaveC:/tmp/..., and the shell'spwdgave/c/tmp/.... Git Bash prints the/c/...form for all of them, andreadlinkprintsd/ffor a relative link target where we printed the stored Win32d\f.New
winux_core::path::shell_display_path— the same display rulecygpath -ualready implements (shell_tree_displaymount name under a shell root, else the/c/drive form) — applied at the emit boundary ofrealpath(all canon modes),readlink(canonicalize modes and verbatim targets), andpwd(physical and valid envPWD).Test plan
winuxcmd-tests: 83/83 onrealpath.*:readlink.*:pwd.*, including the newniu993_section7_all_emitters_share_display_spellingpin asserting all three print the identical pathcargo test -p winux-cmds:realpath::readlink::pwd::canon::greenrealpath d/readlink -f d/f/pwdall agree under/tmpmount and/c/drive formGenerated with Devin