Subject: bug#6194: bug: pwd

From: Bob Proulx <[email-masked]>
Date: Fri, 14 May 2010 13:57:21 -0600

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