Re: Strange symbolic link behaviour?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04Jul2011 23:18, Eric B. <ebenze@xxxxxxxxxxx> wrote:
| I'm running FC14 and running into a strange situation with symbolic
| links that I have never seen or noticed before.
| 
| 
| If I create the following symbolic link:
| [eric@eric-laptop ~]$ pwd
| /home/eric
| [eric@eric-laptop ~]$ ls Mail
| draft  inbox  queue  sent  trash
| [eric@eric-laptop ~]$ ln -s Mail/inbox test
| [eric@eric-laptop ~]$ ls test
| 1  2  3  4  5
| [eric@eric-laptop ~]$ cd test
| [eric@eric-laptop test]$ pwd
| /home/eric/test
| [eric@eric-laptop test]$ ls
| 1  2  3  4  5
| [eric@eric-laptop test]$ ls ..
| draft  inbox  queue  sent  trash
| 
| 
| The strange behaviour here is when listing the parent directory (..).
| In this case, ls .. is listing the contents of Mail/ directory - not
| /home/eric.

ls is behaving correctly. Bash is presenting a ridiculous fiction to you
via its "pwd" builtin, which lies. Try doing your test above again, and
wherever you type "pwd", also run "/bin/pwd" immediately afterwards.
Observe the difference: /bin/pwd tells you the truth and pwd tells you
something easy to remember, but not the truth.

| In the past, I always recall being able to use the parent identified
| (..) to move up one level in the directory structure whether in a
| symlink or not.

It may be that bash subverts the "cd" command also to preserve the
fiction, and you have done a "cd .." and returns from whence you came
(instead of to the "real" upper directory). A symlink is like a teleport
gateway - you are somewhere else if you cd through it. It is not, for
example, like the "mount" command, which really attached is target at
the mount point.

| In this case, I would have expected ls .. to list the
| contents of /home/eric - not /home/eric/Mail.
| Am I wrong?

You are wrong. You expectation has been misled by bash being too clever.

| Am I seeing strange behaviour here?

No. You only think it is strange. What is strange is the behaviour of
the bash pwd builtin (and maybe the cd builtin).

| If so, is there a way
| to enable the behaviour I expect?

alias pwd=/bin/pwd

might remove the scales from your eyes. It is better to fix your
expectations, because a symlink is not a mount. You're expecting it to
act like a mount.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Kilimanjaro is a pretty tricky climb. Most of it's up, until you reach the
very, very top, and then it tends to slope away rather sharply.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux