The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 02-11-2009
larryv larryv is offline
Registered User
  
 

Join Date: Feb 2009
Location: Cambridge, MA, USA
Posts: 1
hmmm

Quote:
Originally Posted by usfish View Post
There is an interview question about UNIX bash:
Funny, that looks an awful lot like one of the extra credit questions on my latest 6.033 (MIT Computer Systems Engineering) homework.

Let's clarify the problem.

Say we have some arbitrary directory at /some/long/path/name/, and say that our home directory is /home/me/.

Now, we do this:
Code:
ln -s /some/long/path/name /foo/bar
ln -s /home/me /foo/baz
So now, assuming that /foo does not contain two directories called bar and baz, we now have two symbolic links, /foo/bar and /foo/baz, that link to /some/long/path/name and /home/me, respectively. If we perform the following:
Code:
bash
cd /foo/bar
cd ../baz
we should end up in /foo/baz, which is really /home/me, because bash traced .. back up to /foo, not to /some/long/path/, as tcsh does (if I'm not mistaken; if not, it used to).

Ultimately, the question is, does bash always get this behavior correct? When cd-ing to another directory via a symlink, does cd .. always get you back to the directory that contains the symlink?

Last edited by larryv; 02-11-2009 at 06:50 PM.. Reason: clarify final sentence