Subject: Re: bug#6194: bug: pwd

From: Eric Blake <[email-masked]>
Date: Fri, 14 May 2010 13:40:39 -0600

On 05/14/2010 01:13 PM, eran shaham wrote:
> from:
> info pwd
> 
> one get:
> `pwd' prints the fully resolved name of the current directory.  That
> is, all components of the printed name will be actual directory
> names--*none will be symbolic links*.

Thanks for the report.  However, this is probably not a bug, but a
misunderstanding on your part.  That sentence is true for 'pwd -P', but
POSIX states that for 'pwd -L', the result can contain symlinks.

POSIX also states that the default must be 'pwd -L'.  With GNU
coreutils, we only default to -L if you have POSIXLY_CORRECT set in your
environment, since many scripts expected 'pwd -P' behavior when invoking
/bin/pwd.

One other thing to remember is the piece of advice given in both the
'/bin/pwd --help' and 'info pwd' pages - your shell probably has a
built-in version of pwd that will supersede /bin/pwd if you don't
qualify which version you are running.  And most built-in pwd's follow
the POSIX rule of -L by default; and at least bash has a shell option
that lets you control whether -L or -P is default.

> 
> When you try the following:
> mkdir dirA dirB
> cd dirA
> ln -s ../dirB/ lnkB
> cd lnkB
> pwd

Try '/bin/pwd' instead of 'pwd' to see the difference.  And to prove to
yourself that you were getting the shell built-in, try 'pwd --help',
contrasted with '/bin/pwd --help'.

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org