Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[BUG] err_exit misbehaviour involving function call inside else



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



Messages sorted by: Reverse Date, Date, Thread, Author