4

On the bash prompt one, three or more slashes (/,///,////, ...) are treated as a single slash, whereas two slashes (//) are left as is:

12:07 $ cd /
12:07 $ pwd
/
12:07 $ cd //
12:07 $ pwd
//
12:07 $ ls
bin  boot  cdrom  dev  etc  home  initrd.img  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  vmlinuz
12:07 $ cd ///
12:07 $ pwd
/
12:07 $ ls
bin  boot  cdrom  dev  etc  home  initrd.img  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  vmlinuz

Usual suspects' versions:

12:07 $ bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)

12:20 $ dpkg-query -s coreutils | grep Version
Version: 8.21-1ubuntu5
iceman
  • 153

1 Answers1

1

For displaying the current directory bash keeps some internal state that doesn't necessarily corresponds to the actual (shortest) path to the current directory. This helps in keeping the path if you cd through soft links.

The cd // (but also when doing e.g. cd //tmp) do not seem to trigger a sanitization of the internal path displayed by pwd, but more than two / seem to trigger this.

Anthon
  • 79,293
  • I guess // does not need sanitisation, since it is implementation-defined. See: http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11. Thanks to @rush for the links above. – iceman Nov 25 '14 at 07:21