Behaviour of .. with symbolic links.

idallen at watmath.UUCP idallen at watmath.UUCP
Tue Mar 27 03:20:08 AEST 1984


In a shell, if X is a symbolic link, then "cd /a/b/c/X/.." does not put
you in directory "/a/b/c".  Similarly, a pwd(1) after "cd /a/b/c/X"
does not print "/a/b/c/X".  My question is, for programs such as the C
Shell that try to keep track of where they are ($cwd), what should
happen?  If you "cd /a/b/c/X", should your $cwd be /a/b/c/X or should
it be what pwd would show?

Another way of looking at this: should the path by which you "arrive"
at a particular directory be the path by which you "leave" using ".."?
Or, should you (as is currently done) always leave by the real link
".."?  Since the C Shell keeps track of how you arrived at a directory,
it could behave either way.

I'm trying to resolve the confusion I feel when I "pass through" a
symbolic link (which I might not have been aware of) and then back up.
The C Shell is behaving half like my mind and half like pwd; thanks to a
bug in the directory resolution function, it sets $cwd as if you back up
along the path by which you got there, but it *really* backs up along
the real link ".." (resulting in complete confusion).

I am afraid that the C Shell will have to be fixed to conform to pwd,
since one wouldn't want "ls .." and "cd ..;ls" to behave differently.
This just means one gets a big surprise when passing through a
symbolic link.  (*sigh*)  Perhaps the shell will have to warn you when
this happens!
-- 
        -IAN!  (Ian! D. Allen)      University of Waterloo



More information about the Comp.unix.wizards mailing list