Jack Hill on 30 Dec 2011 07:24:17 -0800


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

Re: [PLUG] traversing symbolically linked directories with bash


On Thu, 29 Dec 2011, Eric at Lucii.org wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've run across a behavior in bash that I thought was impossible.

I'm running bash on an Ubuntu 10.04 box.
Bash is:  GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)

I have a home directory and I create a soft link to another directory like this example:

  /home/eric/appdata -> /opt/myapplication/users/eric/data

Now I start a shell in my home directory, cd to appdata, and then try to see where I am:

  shell builtin "pwd" returns:    /home/eric/appdata
  executable /bin/pwd returns:    /home/eric/appdata
  ls -l ..                        shows contents of /home/eric
  cd ..                           takes me back to /home/eric

SO FAR, SO GOOD.

Next, I log on to a Debian system.
Linux version 2.6.26-2-686 (Debian 2.6.26-27) (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Wed Sep 21 04:35:47 UTC 2011

I do the same thing...
  shell builtin "pwd" returns:    /home/eric/appdata
  executable /bin/pwd returns:    /opt/myapplication/users/eric/data   <- OOPS!
Here's my problem:
  ls -l ..                        shows contents of /opt/myapplication/users/eric, NOT /home/eric
  cd ..                           takes me back to /opt/myapplication/users/eric,  NOT /home/eric

Is there some bash setting I'm unaware of that causes this behavior?  It makes no sense to me!
I don't even know how to do a Google search for it.  I thought it might be related to some aspect
of posix mode but the behavior remains even after exec bash --posix  or set -o posix.

.. is hard when the filesystem becomes non-hierarchical. Have a look at this Plan 9 article: http://cm.bell-labs.com/sys/doc/lexnames.html

Jack
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug