zsh-users
 help / color / Atom feed
* Unexpected behavior with pipe_fail and err_return
@ 2020-03-28 22:19 Roman Perepelitsa
  2020-03-29 17:29 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Perepelitsa @ 2020-03-28 22:19 UTC (permalink / raw)
  To: Zsh Users

() {
  emulate -L zsh -o pipe_fail -o err_return
  false | while false; do; done
  echo $?
}

This prints "1". Is this expected? I was hoping for no output.

Roman.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Unexpected behavior with pipe_fail and err_return
  2020-03-28 22:19 Unexpected behavior with pipe_fail and err_return Roman Perepelitsa
@ 2020-03-29 17:29 ` Mikael Magnusson
  2020-03-29 17:34   ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2020-03-29 17:29 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Zsh Users

On 3/28/20, Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote:
> () {
>   emulate -L zsh -o pipe_fail -o err_return
>   false | while false; do; done
>   echo $?
> }
>
> This prints "1". Is this expected? I was hoping for no output.

FWIW, you can do this as a workaround
() {
  emulate -L zsh -o pipe_fail -o err_return
  ( false | while false; do; done )
  echo $?
}

-- 
Mikael Magnusson

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Unexpected behavior with pipe_fail and err_return
  2020-03-29 17:29 ` Mikael Magnusson
@ 2020-03-29 17:34   ` Roman Perepelitsa
  0 siblings, 0 replies; 3+ messages in thread
From: Roman Perepelitsa @ 2020-03-29 17:34 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Zsh Users

On Sun, Mar 29, 2020 at 7:29 PM Mikael Magnusson <mikachu@gmail.com> wrote:
> On 3/28/20, Roman Perepelitsa <roman.perepelitsa@gmail.com> wrote:
> > () {
> >   emulate -L zsh -o pipe_fail -o err_return
> >   false | while false; do; done
> >   echo $?
> > }
> >
> > This prints "1". Is this expected? I was hoping for no output.
>
> FWIW, you can do this as a workaround
> [...]

I added `|| return` at the end. Works just as well and doesn't fork.

Is this behavior expected? I thought err_return should trigger
everywhere except for conditions under `if` and `while` and rhs of
`||` and `&&`. Are there additional rules that I'm missing?

Roman.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-28 22:19 Unexpected behavior with pipe_fail and err_return Roman Perepelitsa
2020-03-29 17:29 ` Mikael Magnusson
2020-03-29 17:34   ` Roman Perepelitsa

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git