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

Re: New problem with ERR_RETURN ?



I don't think there is a problem. At least not a new problem because Zsh 5.8 and Zsh dev behave the same way.

Note that if you replace the body of "f" with just "false" you get the same results.

Note also that if you run "return; echo $?" nothing is printed.

From that I concluded that the example behaves correctly. The function "f" returns a non-zero status. Therefore the call to "f" triggers a return, which at the top-level simply exits the script/returns to the command line and thus bypasses what comes next.

Philippe


On Wed, Dec 7, 2022 at 5:17 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
After zsh-workers 51001, 51071, 51076 (Philippe A.)

This seems wrong:

% setopt errreturn
% f() {
    while return 5
    do
        echo fail while1
        break
    done
}
% f ; echo $?
%

Note that "echo $?" was not executed when it appears in the same
command line as "f".  I don't believe ERR_RETURN should be having an
effect there.

Compare:

% f
% echo $?
5
%



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