From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25042 invoked from network); 30 Dec 2005 16:28:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Dec 2005 16:28:54 -0000 Received: (qmail 19297 invoked from network); 30 Dec 2005 16:28:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Dec 2005 16:28:48 -0000 Received: (qmail 10855 invoked by alias); 30 Dec 2005 16:28:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22112 Received: (qmail 10831 invoked from network); 30 Dec 2005 16:28:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Dec 2005 16:28:44 -0000 Received: (qmail 19018 invoked from network); 30 Dec 2005 16:28:44 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 30 Dec 2005 16:28:42 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id 3BD102CB6; Fri, 30 Dec 2005 08:28:41 -0800 (PST) Date: Fri, 30 Dec 2005 08:28:41 -0800 From: Wayne Davison To: Ulrik Haugen Cc: zsh-workers@sunsite.dk Subject: Re: BUG: cd '' doesn't produce an error Message-ID: <20051230162841.GA30078@dot.blorf.net> References: <87zmmvxl3g.fsf@haugen.visit.se> <20051221102159.44d9f5ca.pws@csr.com> <877j9mycf9.fsf@haugen.visit.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877j9mycf9.fsf@haugen.visit.se> User-Agent: Mutt/1.5.11 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..