GNU bug report logs -
#6194
pwd tracks logical paths through symlinks
Previous Next
Reported by: eran.shaham <at> gmail.com
Date: Fri, 14 May 2010 19:23:02 UTC
Severity: normal
Tags: wontfix
Done: Bob Proulx <bob <at> proulx.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6194 in the body.
You can then email your comments to 6194 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6194
; Package
coreutils
.
(Fri, 14 May 2010 19:23:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
eran.shaham <at> gmail.com
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 14 May 2010 19:23:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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*.
When you try the following:
mkdir dirA dirB
cd dirA
ln -s ../dirB/ lnkB
cd lnkB
pwd
you get:
dirA/lnkB
where lnkB is obviously a symbolic link and not an actual directory name.
Best Regards,
Eran Shaham
[Message part 2 (text/html, inline)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6194
; Package
coreutils
.
(Fri, 14 May 2010 19:41:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 6194 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6194
; Package
coreutils
.
(Fri, 14 May 2010 19:58:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 6194 <at> debbugs.gnu.org (full text, mbox):
retitle 6194 pwd tracks logical paths through symlinks
tags 6194 + wontfix
thanks
eran shaham wrote:
> `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*.
Thank you for the report. But you are confusing the coreutils
standalone 'pwd' with your shell's internal builtin 'pwd'. The
coreutils pwd command does not behave as you describe. You are
invoking the shell's builtin pwd.
$ type pwd
pwd is a shell builtin
But regardless of that what you are seeing is the shell's logical path
record keeping in action. This is the behavior that most people
prefer and so it is the default. I can tell taht you however are like
me and do not prefer it. In which case if you are using the bash
shell you can change your shell behavior to use only physical paths.
set -o physical
And now the shell will not track logical paths. Putting that in your
$HOME/.bashrc file will give you the behavior you desire.
> When you try the following:
> mkdir dirA dirB
> cd dirA
> ln -s ../dirB/ lnkB
> cd lnkB
> pwd
The pwd above is the shell's builtin pwd. It is not the coreutils
pwd. The shell tracks the logical path in the PWD environment
variable and reports it as if it were a real path. See the bash pwd
documentation for details.
help pwd
Look at the -L and -P options.
> where lnkB is obviously a symbolic link and not an actual directory name.
That is intentional behavior.
Bob
Changed bug title to 'pwd tracks logical paths through symlinks' from 'bug: pwd'
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Fri, 14 May 2010 19:58:02 GMT)
Full text and
rfc822 format available.
Added tag(s) wontfix.
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Fri, 14 May 2010 19:58:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6194
; Package
coreutils
.
(Fri, 14 May 2010 20:48:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 6194 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks.
I suggest you add into
$man pwd
or
$info pwd
the remark that was on
$ help pwd
pwd: pwd [-LP]
Print the current working directory. With the -P option, pwd prints
the physical directory, without any symbolic links; the -L option
makes pwd follow symbolic links.
It would save other people bothering you on that subject :-)
Thanks,
Eran
On Fri, May 14, 2010 at 22:57, Bob Proulx <bob <at> proulx.com> wrote:
> retitle 6194 pwd tracks logical paths through symlinks
> tags 6194 + wontfix
> thanks
>
> eran shaham wrote:
> > `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*.
>
> Thank you for the report. But you are confusing the coreutils
> standalone 'pwd' with your shell's internal builtin 'pwd'. The
> coreutils pwd command does not behave as you describe. You are
> invoking the shell's builtin pwd.
>
> $ type pwd
> pwd is a shell builtin
>
> But regardless of that what you are seeing is the shell's logical path
> record keeping in action. This is the behavior that most people
> prefer and so it is the default. I can tell taht you however are like
> me and do not prefer it. In which case if you are using the bash
> shell you can change your shell behavior to use only physical paths.
>
> set -o physical
>
> And now the shell will not track logical paths. Putting that in your
> $HOME/.bashrc file will give you the behavior you desire.
>
> > When you try the following:
> > mkdir dirA dirB
> > cd dirA
> > ln -s ../dirB/ lnkB
> > cd lnkB
> > pwd
>
> The pwd above is the shell's builtin pwd. It is not the coreutils
> pwd. The shell tracks the logical path in the PWD environment
> variable and reports it as if it were a real path. See the bash pwd
> documentation for details.
>
> help pwd
>
> Look at the -L and -P options.
>
> > where lnkB is obviously a symbolic link and not an actual directory name.
>
> That is intentional behavior.
>
> Bob
>
[Message part 2 (text/html, inline)]
Reply sent
to
Bob Proulx <bob <at> proulx.com>
:
You have taken responsibility.
(Fri, 14 May 2010 21:03:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
eran.shaham <at> gmail.com
:
bug acknowledged by developer.
(Fri, 14 May 2010 21:03:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 6194-done <at> debbugs.gnu.org (full text, mbox):
eran shaham wrote:
> the remark that was on
> $ help pwd
> pwd: pwd [-LP]
> ...
> It would save other people bothering you on that subject :-)
Well, that documentation comes from 'bash' and we have no control over
it here. But 'help' is a bash command and so all of the documentation
from it is about bash. I don't think it needs more.
The coreutils man page says:
NOTE: your shell may have its own version of pwd, which usually super‐
sedes the version described here. Please refer to your shell’s docu‐
mentation for details about the options it supports.
And the info documentation says:
Because most shells have a built-in `pwd' command, using an
unadorned `pwd' in a script or interactively may get you different
functionality than that described here.
So... I think we are covered there! :-)
Closing the bug ticket.
Bob
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#6194
; Package
coreutils
.
(Fri, 14 May 2010 21:09:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 6194 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
[please don't top-post on technical lists]
On 05/14/2010 02:47 PM, eran shaham wrote:
> Thanks.
> I suggest you add into
> $man pwd
'man pwd' is auto-generated from '/bin/pwd --help'. Here's the output I
get when using pwd from coreutils 8.4:
> $ /bin/pwd --help
> Usage: /bin/pwd [OPTION]...
> Print the full filename of the current working directory.
>
> -L, --logical use PWD from environment, even if it contains symlinks
> -P, --physical avoid all symlinks
> --help display this help and exit
> --version output version information and exit
>
> NOTE: your shell may have its own version of pwd, which usually supersedes
> the version described here. Please refer to your shell's documentation
> for details about the options it supports.
>
> Report pwd bugs to bug-coreutils <at> gnu.org
> GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
> General help using GNU software: <http://www.gnu.org/gethelp/>
> For complete documentation, run: info coreutils 'pwd invocation'
Note that we already do mention the possibility of a shell built-in, as
well as cleaner wording on when symlinks are avoided. The --help output
is terse, and doesn't really mention the effects of POSIXLY_CORRECT, nor
the fact that shells tend to default to -L while coreutils defaults to
-P unless POSIXLY_CORRECT, but there's only so much you can cram in one
screen-full. But at the time that I implemented /bin/pwd -L for
coreutils 7.2, I took care to also edit 'info pwd' in a similar manner,
where I did go into those extra details.
Most likely, your confusion stems from using an earlier version of
coreutils, prior to 7.2, where the coreutils man page was definitely
more biased towards 'pwd -P' behavior. But if you still think that
there is anything to tweak in the current upstream documentation, we'd
like to hear about it.
--
Eric Blake eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 12 Jun 2010 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 15 years and 62 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.