zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] 'cd -P' leaves double slash in $PWD
@ 2020-02-01  2:15 Martijn Dekker
  2020-02-01  4:23 ` Daniel Shahaf
  0 siblings, 1 reply; 2+ messages in thread
From: Martijn Dekker @ 2020-02-01  2:15 UTC (permalink / raw)
  To: Zsh hackers list

$ zsh -c 'cd -P ////dev//; echo $PWD'
//dev

Expected output: /dev

A double initial slash in a canonicalised/normalised path is okay if the 
original started with a double slash (as this could signify a Cygwin UNC 
network path), but not if it started with one or more than two slashes.

Bug confirmed on zsh from current back to 5.0.8 (I didn't test earlier 
versions).

-- 
modernish -- harness the shell
https://github.com/modernish/modernish

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG] 'cd -P' leaves double slash in $PWD
  2020-02-01  2:15 [BUG] 'cd -P' leaves double slash in $PWD Martijn Dekker
@ 2020-02-01  4:23 ` Daniel Shahaf
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2020-02-01  4:23 UTC (permalink / raw)
  To: Martijn Dekker; +Cc: Zsh hackers list

Martijn Dekker wrote on Sat, 01 Feb 2020 03:15 +0100:
> $ zsh -c 'cd -P ////dev//; echo $PWD'
> //dev
> 
> Expected output: /dev
> 
> A double initial slash in a canonicalised/normalised path is okay if the 
> original started with a double slash (as this could signify a Cygwin UNC 
> network path), but not if it started with one or more than two slashes.
> 
> Bug confirmed on zsh from current back to 5.0.8 (I didn't test earlier 
> versions).
> 

Thanks.  Tests:

diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst
index 3312f8707..ed56d839f 100644
--- a/Test/B01cd.ztst
+++ b/Test/B01cd.ztst
@@ -145,6 +145,10 @@ F:something is broken.  But you already knew that.
 1:Implicit cd with unset HOME.
 ?zsh:cd:1: HOME not set
 
+ $ZTST_testdir/../Src/zsh -fc 'cd -P ////dev && pwd'
+-f:cd -P squashes multiple leading slashes
+>/dev
+
 %clean
 # This optional section cleans up after the test, if necessary,
 # e.g. killing processes etc.  This is in addition to the removal of *.tmp
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 3d7df94c9..76e1132c3 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -742,6 +742,10 @@
 >glob.tmp/secret-s111/  glob.tmp/secret-s111
 >glob.tmp/secret-s444/  glob.tmp/secret-s444
 
+ () { echo $1:P } ////dev
+-f:modifier ':P' squashes multiple slashes
+>/dev
+
 %clean
 
  # Fix unreadable-directory permissions so ztst can clean up properly

That doesn't handle the Cygwin double slashes case, but I don't have a
Cygwin box to test on.  If someone knows how to change the expectations
for Cygwin, please do.

@all Please don't consider fixing this bug to be a licked cookie.
I.e., if you want to look into fixing this, please do; I'm _not_ taking
ownership of that.  Thanks.

Cheers,

Daniel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-01  4:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-01  2:15 [BUG] 'cd -P' leaves double slash in $PWD Martijn Dekker
2020-02-01  4:23 ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).