Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: BUG: cd '' doesn't produce an error



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