change dir to //

Eric Blake eblake at redhat.com
Mon Jan 17 14:13:08 UTC 2011


On 01/16/2011 03:54 PM, Michał Piotrowski wrote:
> Hi,
> 
> I wonder why such a thing is possible
> [michal at ozzy ~]$ cd /
> [michal at ozzy /]$ pwd
> /
> [michal at ozzy /]$ cd //
> [michal at ozzy //]$ pwd
> //

Because POSIX says that leading // is allowed (but not required) to have
a separate interpretation from / (no other spelling gets this special
treatment; leading /// must be identical to leading /).  Some systems,
like Cygwin, use this POSIX requirement to implement an alternate access
space, where //server/share is used, in perfect compliance with POSIX,
to represent windows remote share drives.  Since bash is ported to
cygwin, the bash maintainer chose to preserve // as special for all
systems, whether or not it actually is special.  On Linux, it happens to
not be special.  Other shells, like zsh, only treat // as special on
platforms where it really is special, and collapse it to / otherwise.

However, you have not pointed out any bugs - since POSIX is explicit
that // is special, you are better off avoiding // and not worrying
about whether a program collapses // into /.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
Url : http://lists.fedoraproject.org/pipermail/test/attachments/20110117/a2e9472a/attachment.bin 


More information about the test mailing list