From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14701 invoked by alias); 14 May 2014 15:10:36 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18806 Received: (qmail 15368 invoked from network); 14 May 2014 15:10:30 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140514081026.ZM24282@torch.brasslantern.com> Date: Wed, 14 May 2014 08:10:26 -0700 In-reply-to: <891422cb1f2a28c07029a09041a120da@xgm.de> Comments: In reply to Florian Lindner "Re: Stop script if one command returns != 0" (May 14, 4:31pm) References: <20140514152011.7a811dcb@pwslap01u.europe.root.pri> <891422cb1f2a28c07029a09041a120da@xgm.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Stop script if one command returns != 0 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On May 14, 4:31pm, Florian Lindner wrote: } } > (Count the responses. I'm guessing 3 to 5...) } } :-P Wrong time of day in the USA for that guess, Peter ... } > set -e } > } > is standard across Bourne-like shells including zsh --- this is } > equivalent to the zsh option "ERREXIT". } } Problem is that set -e or ERREXIT kill my shell when called in a sourced } script. This should work: trap 'return $?' ZERR Or if you want to get fancier: [[ -o interactive ]] && trap 'return $?' ZERR || set -e To remove the trap automatically (very recent zsh versions only): trap '(){ trap - ZERR; return $1 } $?' ZERR