-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Till Halbach on 2/6/2009 4:23 AM: > I have come over something which I think of as a bug, but you might > disagree.
Not a bug; POSIX requires this behavior. > > Consider > $ cd > $ mkdir dir1 dir2 > $ cd dir1 > $ ln -s ../dir2 link > $ cd link > $ pwd > gives $HOME/dir1/link > but > $ ls .. > lists $HOME instead of dir1. That is because cd and pwd have two different behaviors, both mandated by POSIX - physical (-P), which behaves like the getpwd system call, and logical (-L), which remembers how you got to the current location; POSIX also states that if neither -P nor -L is given, then -L should be assumed. cd is always a shell builtin (there is no other way to implement it), while pwd is typically a shell builtin in addition to being provided by coreutils. Coreutils does not yet implement pwd -L or -P, and always behaves as if -P had been specified, but that feature has been requested frequently over the years (in part because it means coreutils does not obey POSIX in this regards). In the meantime, since you did not give absolute paths to pwd, you probably got the shell's builtins, which both behave logically; hence your listing of pwd returning $HOME/dir1/dir2. But physical vs. logical paths only make sense in a limited number of settings, such as cd and pwd. Most applications always behave physically, including ls. This is due to the leaky abstraction caused by having two means of tracking current location in the shell, but only one means of tracking it once you leave the shell. If it bothers you that much, then add an alias or shell function to supply the -P argument to your shell's cd and pwd commands. - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkmNmcQACgkQ84KuGfSFAYCtQQCeKHkZngohmTdu3w30O8sS9MYc ISUAoJEtBLgxCmaYBUiGRulfj80nLo6/ =Rh78 -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
