From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15235 invoked by alias); 5 Nov 2012 08:33:47 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30776 Received: (qmail 4477 invoked from network); 5 Nov 2012 08:33:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at linux.vnet.ibm.com does not designate permitted sender hosts) Date: Mon, 5 Nov 2012 16:22:50 +0800 From: Han Pingtian To: zsh-workers@zsh.org Subject: Re: Function code breaking out of if then ...fi Message-ID: <20121105082250.GA2200@localhost.localdomain> References: <121102143911.ZM14168@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <121102143911.ZM14168@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12110508-7282-0000-0000-00000E9F535A On Fri, Nov 02, 2012 at 02:39:11PM -0700, Bart Schaefer wrote: > On Nov 2, 10:09am, Michal Maruska wrote: > } > } I wonder if the following behaviour is a bug, or > } simply my wrong expectation: > } > } This script, assuming the globbing fails, and I'm not using NULL_GLOB, > } does not bother finishing the commands in the "then ....fi" block, > } instead continues after "fi". > > This doesn't really have anything to do with the function. The same > thing happens with > > if true; > then > echo non-existing* > exit 0 > fi > > What slightly surprises me is that a glob failure isn't considered an > error for purposes of ERR_EXIT (the -e option in your #! line). I > would have expected the whole script to quit at that point, but I guess > glob errors are not treated as command failures because the command > never executes in the first place. > On my latop, if use 'echo non-existing*' in the if command, the script will exit immediately, looks like the glob failure is considered an error of ERR_EXIT. And changing to { echo non-existing* } always { TRY_BLOCK_ERROR=0 } doesn't help, it still exits immediately. In the contrast, using 'fn' won't trigger ERR_EXIT.