Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.shell > #4871

[zsh] How to mimic errexit within subshell (or function)?

From kj <no.email@please.post>
Newsgroups comp.unix.shell
Subject [zsh] How to mimic errexit within subshell (or function)?
Date 2012-05-01 21:20 +0000
Organization none
Message-ID <jnpk36$jqs$1@reader1.panix.com> (permalink)

Show all headers | View raw



The following scheme doesn't work as expected: despite the set -e
(errexit), the subshell does not exit on error (it just goes on to
execute the next command):

#!/usr/bin/zsh
(
  set -e
  cmd0...
  cmd1...
  cmd2...
  ...
  echo "$0: done" 
) || { echo "$0: failed" && exit 1 }

How can I mimic the behavior of "set -e" within a subshell?  (Or
within a function, for that matter?)  (I realize that I can always
append "|| exit 1" to every command, but this is precisely what
I'd like to avoid.)

Thanks!

~kj

Back to comp.unix.shell | Previous | NextNext in thread | Find similar


Thread

[zsh] How to mimic errexit within subshell (or function)? kj <no.email@please.post> - 2012-05-01 21:20 +0000
  Re: [zsh] How to mimic errexit within subshell (or function)? Stephane Chazelas <stephane.chazelas@gmail.com> - 2012-05-02 07:34 +0100
    Re: [zsh] How to mimic errexit within subshell (or function)? Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2012-05-02 13:51 +0100
      Re: [zsh] How to mimic errexit within subshell (or function)? Stephane Chazelas <stephane.chazelas@gmail.com> - 2012-05-02 14:29 +0100
    Re: [zsh] How to mimic errexit within subshell (or function)? kj <no.email@please.post> - 2012-05-02 19:33 +0000
      Re: [zsh] How to mimic errexit within subshell (or function)? Stephane Chazelas <stephane.chazelas@gmail.com> - 2012-05-02 20:53 +0100
  Re: [zsh] How to mimic errexit within subshell (or function)? Martin Vaeth <vaeth@mathematik.uni-wuerzburg.de> - 2012-05-02 10:30 +0000
    Re: [zsh] How to mimic errexit within subshell (or function)? kj <no.email@please.post> - 2012-05-02 19:09 +0000
      Re: [zsh] How to mimic errexit within subshell (or function)? kj <no.email@please.post> - 2012-05-02 19:12 +0000
      Re: [zsh] How to mimic errexit within subshell (or function)? Stephane Chazelas <stephane.chazelas@gmail.com> - 2012-05-02 20:27 +0100
        Re: [zsh] How to mimic errexit within subshell (or function)? kj <no.email@please.post> - 2012-05-03 18:20 +0000

csiph-web