Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG: cd '' doesn't produce an error
- X-seq: zsh-workers 22111
- From: Ulrik Haugen <qha@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: BUG: cd '' doesn't produce an error
- Date: Fri, 30 Dec 2005 13:52:42 +0100
- Cancel-lock: sha1:rHibJZME1oxTnA9/QJuM2i7V5tk=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <87zmmvxl3g.fsf@xxxxxxxxxxxxxxx> <20051221102159.44d9f5ca.pws@xxxxxxx>
- Sender: news <news@xxxxxxxxxxxxx>
Hello!
Peter Stephenson <pws@xxxxxxx> wrote:
> Ulrik Haugen <qha@xxxxxxxxxxxxxx> wrote:
>> I recently discovered that zsh (versions 4.2.5 and 4.3.0-dev-1)
>> doesn't produce an error when i attempt to "cd ''" (in version 3.0.8 I
>> get the error i expected). Please let me know if you'd like me to test
>> any other versions.
> It's certainly strange, although it's not wholly illogical with $cdpath: as
> the empty string is not an absolute directory nor begins with . or .., the
> shell looks through $cdpath for the first directory for which the
> concatenation with the empty string exists, which is usually just the first
> directory in $cdpath. This is almost useful... It's easy to add an error
> but I'm not quite sure at what stage the behaviour actually is an error in
> this case: it's a correct, if unexpected, interpretation of the cdpath
> rules.
Sorry for taking so long to reply, but I haven't had the time to look
into properly this until now.
I'm still not quite satisfied with this behaviour for a couple of
reasons:
In my tests I had not set cdpath, so I don't see why the shell should
go through any cdpath rules.
If I try
% cd /tmp; CDPATH=/usr cd ''
I still wind up in /tmp, so it doesn't seem to have that much to do
with cdpath to me.
If I had ended ended up in /usr, I'm not really sure I'd like that
either (although someone who uses cdpath is probably a better judge).
My intuitive expectation was that cd would successively cd to each
component of cdpath, try to cd to the argument given and be satisfied
at the first successful cd (though obviously just appending "/$arg" to
each component in cdpath and successively trying to cd to that is
cheaper).
The reason I take the time to argue about this is that I often want to
determine the absolute path my scripts are called from in this
fashion:
scriptdir=`dirname "$0"`
scriptdir=`cd "$scriptdir"&& pwd`
More than once I've decided I'm not happy with whatever variable name
has had the role of scriptdir and only changed the occurences at the
beginnings of lines. Right now zsh silently ignores my error and I'll
get the callers present working directory in the whatever new name
I've chosen for scriptdir. Admittedly I'd get a faulty value if zsh
complained to, but at least I'd get some indication of my mistake.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author