You are not logged in.

#1 2010-01-06 01:02:47

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Aliases and .. in bash

I asked about this a while back http://bbs.archlinux.org/viewtopic.php?id=79301, but we didn't get it figured out.

Try this:

 $ mkdir -p $HOME/test/{alpha,beta}
 $ cd $HOME/test/alpha
 $ touch one
 $ ln -s $HOME/test/beta alphabeta
 $ cd alphabeta
 $ pwd
 /home/jim/test/alpha/alphabeta
 $ pwd -P
 /home/jim/test/beta
 $ ls ../o<here press tab>

If you have bash-completion activated, then pressing tab will correctly autocomplete to give you:

 $ ls ../one

So for autocompletion .. pays attention to your logical working directory, whose (logical) parent is ~/test/alpha.

However look at the output of the ls command:

ls: cannot access ../one: No such file or directory

Huh? It looks like the ls command itself is interpreting .. to refer to the directory's physical parent instead. Who would want to do that?
If that's what I wanted, I would "cd -P ." first.

This behavior has been plaguing me for all of Bash 4.x. I haven't gone back to Bash 3.x but I really don't think it was always this way. (I wouldn't be so surprised everytime it happens if I've been dealing with it for years.)

In my previous post, others reported not seeing this same behavior. So I thought it might be something in my .bashrc. But even if I move all my bash-related dotfiles elsewhere and start a new shell, I still get this problem. Can others at least report in whether they see this behavior too?

I just now tried building and installing the new bash 4.1 (and readline 6.1) that were just released, but I get the problem with them too.

Offline

#2 2010-01-06 01:57:53

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: Aliases and .. in bash

I get the same result on BASH 4.0.35:

[mike@mac|~/test] $ ls -ia {alpha,alpha/alphabeta,beta}
alpha:
658340 .  658333 ..  658343 alphabeta  658342 one

alpha/alphabeta:
658341 .  658333 ..

beta:
658341 .  658333 ..

That is alpha, alpha/alphabeta and beta all have the same parent according to ls. Can't say this has ever been an issue for me though.

Offline

Board footer

Powered by FluxBB