Bug 688856

Summary: pwd returns //
Product: Red Hat Enterprise Linux 6 Reporter: Lubos Kocman <lkocman>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: low Docs Contact:
Priority: low    
Version: 6.1CC: meyering, ovasik, prc, tsmetana
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-03-22 11:39:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Lubos Kocman 2011-03-18 09:22:42 UTC
Description of problem:

bash-4.1$ export PS1="[\u@\h \W]$"
[lkocman@dhcp-28-248 Desktop]$cd //
[lkocman@dhcp-28-248 //]$pwd
//
[lkocman@dhcp-28-248 //]$ls
bin   cgroup  etc   lib    lost+found  misc  net  proc  sbin     srv  tmp  var
boot  dev     home  lib64  media       mnt   opt  root  selinux  sys  usr
[lkocman@dhcp-28-248 //]$rpm -qf `which pwd`
coreutils-8.4-12.el6.x86_64

[lkocman@dhcp-28-248 //]$


Version-Release number of selected component (if applicable):

bash-4.1.2-8.el6.x86_64
coreutils-8.4-12.el6.x86_64

How reproducible:


Steps to Reproduce:
1. export PS1="[\u@\h \W]$"
2. cd //
3. pwd
  
Actual results:

// (is this really wanted behaviour?)

Expected results:

/ 

Additional info:

Comment 1 Lubos Kocman 2011-03-18 09:24:56 UTC
cd /// and more returns /

Comment 2 Jim Meyering 2011-03-18 09:29:50 UTC
This does not involve coreutils, but rather bash's built-in pwd:

  $ bash -c 'cd //; env pwd'
  /

  $ bash -c 'cd //; pwd'
  //

I've changed the component from coreutils to bash.

Comment 5 Roman Rakus 2011-03-18 12:23:03 UTC
(In reply to comment #0)
> Description of problem:
> 
> bash-4.1$ export PS1="[\u@\h \W]$"
> [lkocman@dhcp-28-248 Desktop]$cd //
> [lkocman@dhcp-28-248 //]$pwd
> //
> [lkocman@dhcp-28-248 //]$ls
> bin   cgroup  etc   lib    lost+found  misc  net  proc  sbin     srv  tmp  var
> boot  dev     home  lib64  media       mnt   opt  root  selinux  sys  usr
> [lkocman@dhcp-28-248 //]$rpm -qf `which pwd`
> coreutils-8.4-12.el6.x86_64
> 
> [lkocman@dhcp-28-248 //]$
> 
> 
> Version-Release number of selected component (if applicable):
> 
> bash-4.1.2-8.el6.x86_64
> coreutils-8.4-12.el6.x86_64
> 
> How reproducible:
> 
> 
> Steps to Reproduce:
> 1. export PS1="[\u@\h \W]$"
> 2. cd //
> 3. pwd
> 
> Actual results:
> 
> // (is this really wanted behaviour?)
Yes it is.
> 
> Expected results:
> 
> / 
> 
> Additional info:

See http://www.faqs.org/faqs/unix-faq/shell/bash/ E10

Comment 7 Lubos Kocman 2011-03-22 10:00:22 UTC
bash-4.1$ cd //
bash-4.1$ /bin/pwd 
/
bash-4.1$ pwd
//


Problem is bash.

Comment 8 Ondrej Vasik 2011-03-22 11:26:38 UTC
Have you read the faq Roman posted in comment #10 ?

Cite:
"
E10) Why does `cd //' leave $PWD as `//'?

POSIX.2, in its description of `cd', says that *three* or more leading
slashes may be replaced with a single slash when canonicalizing the
current working directory.

This is, I presume, for historical compatibility.  Certain versions of
Unix, and early network file systems, used paths of the form
//hostname/path to access `path' on server `hostname'.
"

So the bash behaviour seems to be really intentional. I'll leave it up on you or Roman to close it again notabug .