Re: CDPATH and shell builtins. Need explanation of how it works.
From: David Thompson (dat1965_at_yahoo.com)
Date: 10/17/03
- Next message: Dan Mercer: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Previous message: Darren Dunham: "Re: Well... Let's test it?"
- In reply to: Barry Margolin: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Next in thread: Dan Mercer: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Reply: Dan Mercer: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Reply: Barry Margolin: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 17 Oct 2003 18:23:33 GMT
"Barry Margolin" <barry.margolin@level3.com> wrote
> J Peterman <mrpeterman@hotmail.com> wrote:
> >What I am thinking is that when you type in "cd pathname", the function
> >should search all the paths listed in the CDPATH environment variable,
and
> >if it finds it, make the current directory "pathname".
> >
> >Is this correct?
>
> Not quite. It tries to find "pathname" relative to each of the paths in
> CDPATH. E.g. if CDPATH contains /dir1/dir2:/other/dir, it will look for
> /dir1/dir2/pathname and /other/dir/pathname. If it finds one of them, it
> will make the current directory that full path.
Yeah, and it cd's to that directory despite the specified
pathname existing in your current directory. Which is why
I eventually decided CDPATH wasn't all that useful for my
purposes. I eventually found CDPATH annoying. Why?
Observe this ksh93 simple test scenario,
$ PATH=/bin:/usr/bin
$ unalias cd
$ CDPATH=/tmp
$ export CDPATH
$ mkdir /tmp/dummy
Now type this innocent sequence,
$ cd
$ mkdir dummy
$ cd dummy
and observe, the resulting chdir annoyingly ignored the
fact that 'dummy' exists in the current directory,
$ pwd
/tmp/dummy
I'd prefer ksh93 to cd to $HOME/dummy. I don't think
retraining my fingers to do,
$ cd ./dummy
was worth putting the ./ in front of *every* cd command,
just to keep CDPATH from hijacking my intentions. I'd
always prefer to just chdir to the specified path relative
to the current directory, if it exists, and only use the
CDPATH if it's not found. Forcing my intentions known and
typing ./ to mean current directory became annoying, but
using CDPATH means you add ./ alot to your cd commands. Ie,
for me, using CDPATH forced me to become explicit (overly so)
on what used to be an assumed feature of the cd command.
The design of CDPATH is that it takes precedance over
looking in the current directory, do you know of any way
to reverse this search order? I'd want CDPATH consulted
only as a last resort.
-- David Thompson Foster City, CA
- Next message: Dan Mercer: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Previous message: Darren Dunham: "Re: Well... Let's test it?"
- In reply to: Barry Margolin: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Next in thread: Dan Mercer: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Reply: Dan Mercer: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Reply: Barry Margolin: "Re: CDPATH and shell builtins. Need explanation of how it works."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|