zsh-workers
 help / color / mirror / 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

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git