Re: "return" should not continue script execution, even if used inapprop
From:
Chet Ramey
Subject:
Re: "return" should not continue script execution, even if used inappropriately
Date:
Mon, 7 Jan 2019 09:15:55 -0500
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0
On 1/7/19 4:15 AM, Robert Elz wrote:
> Date: Sun, 6 Jan 2019 17:22:36 -0500
> From: Chet Ramey <chet.ramey@case.edu>
> Message-ID: <ec0b765e-3524-1e17-b9ef-40c103ad06cb@case.edu>
>
> | Bash, in its default mode, considers errors from builtins non-fatal. When
> | you run this in posix mode, which makes a distinction between "special"
> and
> | "regular" builtins, it should be a fatal error because POSIX says a non
> | interactive shell needs to exit if a special builtin fails. It's a bug in
> | bash if it doesn't do that in posix mode.
>
> But return is not required to fail if it does not appear in a function or .
> script, what POSIX says is ...
Sure. But if it returns non-zero in default mode, it should return non-zero
in posix mode. And if it returns non-zero in posix mode, the shell should
exit, because it's a special builtin.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/