zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] err_exit misbehaviour involving function call inside else
@ 2017-12-14 22:40 dana
  2017-12-14 23:00 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: dana @ 2017-12-14 22:40 UTC (permalink / raw)
  To: zsh-workers

I'm afraid i have another one.

The following script prints '0' in ksh93, dash, and bash, but '1' in zsh:

  fn() { return 1; }
  (
    set -e
    if [ x = y ]; then
      fn || :
    else
      fn || :
    fi
    :
  )
  echo $?

It doesn't attempt to execute the `|| :` part at all, just immediately returns
after `fn`.

It seems like it has something to do specifically with calling a function inside
the body of an `else`. If i change `x = y` to `x = x`, then the first `fn || :`
behaves as expected. Or if i change `fn` to `false`, that works too. Or if i
remove the conditional entirely.

Unfortunately i ran up against my inexperience again trying to track it down.

dana


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

end of thread, other threads:[~2017-12-15  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 22:40 [BUG] err_exit misbehaviour involving function call inside else dana
2017-12-14 23:00 ` Bart Schaefer
2017-12-15  7:51   ` dana

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).