Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.shell > #4874
| Newsgroups | comp.unix.shell |
|---|---|
| From | Geoff Clare <geoff@clare.See-My-Signature.invalid> |
| Subject | Re: [zsh] How to mimic errexit within subshell (or function)? |
| References | <jnpk36$jqs$1@reader1.panix.com> <20120502063438.GA10446@chaz.gmail.com> |
| Date | 2012-05-02 13:51 +0100 |
| Message-ID | <f8n779-hk5.ln1@leafnode-msgid.gclare.org.uk> (permalink) |
| Organization | Zen Internet |
Stephane Chazelas wrote:
> 2012-05-01 21:20:38 +0000, kj:
>>
>> 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 }
> Try
>
> zsh -ec '
> cmd1
> cmd2...
> ' || ...
Or try
(
set -e
cmd1
cmd2...
)
test $? -eq 0 || ...
(I don't have zsh, but that works in ksh, bash and dash).
--
Geoff Clare <netnews@gclare.org.uk>
Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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