bug-bash
[Top][All Lists]
Advanced

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

Re: ca - New bash command proposal


From: Rolf Brudeseth
Subject: Re: ca - New bash command proposal
Date: Thu, 12 Feb 2009 22:19:42 -0600
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

Mike Frysinger wrote:
On Thursday 12 February 2009 04:58:09 Andreas Schwab wrote:
Mike Frysinger <vapier@gentoo.org> writes:
On Wednesday 11 February 2009 23:38:10 Rolf Brudeseth wrote:
I would like to propose a new command for bash:

ca [path]

It returns the canonical path based on the current working directory and
entered path.


If the current working directory has been traversed through a symbolic
link, then listing a higher level path using dotdot's do not always show
I am looking for. Below is a trivial example:
what's wrong with:
ca() { cd "$(readlink -f -- "$@")"; }
It doesn't work. See below.
ca() { (cd "$@" && pwd -P); }
Yes, that does the trick:

rolfb@otto:~/test/B/BB$ ca() { (cd "$@" && pwd -P); }

rolfb@otto:~/test/B/BB$ ca ..
/home/rolfb/test/B

~/test/B/BB$ ca ..|xargs ls -l
total 0
-rw-r--r-- 1 rolfb rolfb 0 2009-02-05 23:59 b
lrwxrwxrwx 1 rolfb rolfb 7 2009-02-06 00:09 BB -> ../A/AA

yes, that would be correct ... i thought he wanted to change to the canonical path, not look it up
-mike
Even if I wanted to change the path, it does not take me to '~/test/B':

rolfb@otto:~/test/B/BB$ ca() { cd "$(readlink -f -- "$@")"; }
rolfb@otto:~/test/B/BB$ ca ..
rolfb@otto:~/test/A$

rolfb@otto:~/test/B/BB$ readlink -f ..
/home/rolfb/test/A
rolfb@otto:~/test/B/BB$


I get exposed to this on a multitude of systems both at my place of employment as well as at my ISP, so I thought this would be seen often enough to where a separate command would be appropriate. Or maybe it belongs with coreutils instead?


If nothing else, it gave me an excuse to delve into the inner workings of bash.

Rolf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]