[TriLUG] Bash Symbolic Link Traversal Question

Roadrunner mamiano at nc.rr.com
Thu Jul 5 13:23:13 EDT 2012


Iirc, the sym link points to the string-ish pathname, not an inode or any deeper structure, and there is no knowledge of the sym link from the perspective of the target of the link. The filesystem knows about '.' and '..' relative to the data structures it maintains; bash traversing does not do anything to change those properties, as they are not properties of the shell but of the underlying filesystem. It can work incidentally if your link happens to be in the same directory as its target, or if .. gets to a different folder that also happens to have, directly or through links, the resources your script is trying to open. 

  

Sent from my iPad

On Jul 5, 2012, at 11:44 AM, Ken Mink <ken.mink at gmail.com> wrote:

> Hey Folks,
>   I've been doing a lot of googling on this problem and can't seem to find a bash setting to make me happy.
> I do the following:
> mkdir /tmp/dir1
> mkdir /tmp/dir2
> echo "Testing 1 2 3" > /tmp/dir1/test
> ln -s /tmp/dir2 /tmp/dir1/dir2
> cd /tmp/dir1/dir2
> cat ../test
> 
> I'm running Ubuntu 12.04 and using bash and I get "cat: ../test: No such file or directory". Tab completion found 'test', but cat did not. cat looked in /tmp since it's the parent directory of the real dir2 not in /tmp/dir1 which is the parent directory of the symbolic link dir2 that I traversed.
> 
> I swear this has worked in the past. Does anyone know if it's possible to make this work?
> 
> Thanks,
> Ken
> -- 
> This message was sent to: Mitch Amiano <mamiano at nc.rr.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web    : http://www.trilug.org/mailman/options/trilug/mamiano%40nc.rr.com
> TriLUG FAQ          : http://www.trilug.org/wiki/Frequently_Asked_Questions



More information about the TriLUG mailing list