From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11997 invoked by alias); 14 May 2014 14:49:42 -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: 18804 Received: (qmail 18087 invoked from network); 14 May 2014 14:49:26 -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, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7fae6d000004d6d-f8-537382721e9d Date: Wed, 14 May 2014 15:49:21 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: Stop script if one command returns != 0 Message-id: <20140514154921.3b92a8f4@pwslap01u.europe.root.pri> In-reply-to: <20140514153544.44c4cd7b@pwslap01u.europe.root.pri> References: <355857b792fd08eade06510fd648684d@xgm.de> <20140514153544.44c4cd7b@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42I5/e/4Vd2ipuJgg+lXLS12nFzJ6MDoserg B6YAxigum5TUnMyy1CJ9uwSujKvH+tgL3rFUrJ0zm7WB8S5zFyMnh4SAicSt2zfYIGwxiQv3 1gPZXBxCAksZJSbtvMcI5TBJ3G6ZxAJSxSKgKtH9aicjiM0mYCgxddNsMFtEQFRi+YrN7CC2 MNDU+ysWgdm8AvYSKw9/ANvAKeAgcW/9LFYQW0hgOqPEvXMGIDa/gL7E1b+fmCCusJeYeeUM I0SvoMSPyffA9jILaEls3tbECmHLS2xe85Z5AqPALCRls5CUzUJStoCReRWjaGppckFxUnqu kV5xYm5xaV66XnJ+7iZGSBB+3cG49JjVIUYBDkYlHt6fq4qChVgTy4orcw8xSnAwK4nwLq4v DhbiTUmsrEotyo8vKs1JLT7EyMTBKdXAWHREQWyFfYTJzCVyiTNWX/Ppdv7+fLFA97yg0y/X 3OWQTvAQl2RMMpus/m6FMq8l14++5TyF7jUHuVZ8F3O2/Lrhv/V6vv1iNdnavya/C3QMPPP9 ZMJuybC8ZyWTAoMkv/7KWCR5JIzpwdN7fbWp9/5brn9TK//KXVBjDeuyqh91++xSpmksUmIp zkg01GIuKk4EABFe0c0gAgAA On Wed, 14 May 2014 15:35:44 +0100 Peter Stephenson wrote: > Wrap your sourced file in a function and use the zsh-specific option > ERR_RETURN. > > source_with_err_return() { > setopt localoptions errreturn > source "$@" > } (I haven't got the reposted mail I'm replying to yet, so you might see this first...) It turns out I was accidentally or otherwise smart enough to make err_return apply to sourced files, so if you don't want function scope you can get away with... { setopt err_return source ./script } always { unsetopt err_return } pws