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

Re: Stop script if one command returns != 0



Florian Lindner sent me the following 0.2K:

> I have a script that I source with a number of commands and exports.
> Is there a way to tell zsh (or even in a portable way to sh) to stop
> execution of this script if any of the commands returns a return
> code other than zero?

Setting the ERR_EXIT option will cause the script to bail:

setopt ERR_EXIT
ls "file does not exist"                                                                                                                                                           
echo "this won't appear"

-- 
Chris Johnson
johnch@xxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author