Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG: cd '' doesn't produce an error
- X-seq: zsh-workers 22112
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Ulrik Haugen <qha@xxxxxxxxxxxxxx>
- Subject: Re: BUG: cd '' doesn't produce an error
- Date: Fri, 30 Dec 2005 08:28:41 -0800
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <877j9mycf9.fsf@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <87zmmvxl3g.fsf@xxxxxxxxxxxxxxx> <20051221102159.44d9f5ca.pws@xxxxxxx> <877j9mycf9.fsf@xxxxxxxxxxxxxxx>
On Fri, Dec 30, 2005 at 01:52:42PM +0100, Ulrik Haugen wrote:
> Right now zsh silently ignores my error
It would be better to address this aspect of the problem rather than
trying to change the cd command. There are a couple ways to deal with
this:
1. Specify "setopt no_unset err_exit" in the script. This will ensure
that no unset variable will ever be silently expanded into an empty
string unless you explicitly request it via ${FOO:-} .
2. Use a single must-be-defined check via ${FOO:?}, like this:
scriptdir=`dirname "$0"`
scriptdir=`cd "${scriptdir:?}"&& pwd`
That will output a "parameter not set" error for a single variable
instead of all variables. The documentation claims that this error
should cause the shell to exit, but in my testing it did not do so
without the err_exit option also being set.
..wayne..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author