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

Unexpected err_return behavior inside if/else block



The following script outputs "status: 1", where I'd expect the script
to exit right after the called function failed with the `false`
statement:

    #!/usr/bin/env zsh

    setopt err_return
    function { if :; then false; fi }
    echo status: $?

But if the function is replaced in the following way, the last line
is never reached (as I expected):

    #!/usr/bin/env zsh

    setopt err_return
    function { true && false }
    echo status: $?

It seems that the "err_return" option is not respected by the caller
when the called function is exited from inside an if/else block (and
other blocks too e.g. `repeat 1 { false }` or `for i in 1; { false }`).

Is this the intended behavior, or is it a bug?



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