Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Stop script if one command returns != 0
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author