[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Sun, 6 Jan 2019 17:22:36 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.3.3

On 1/5/19 2:16 PM, Robert Hailey wrote:
> To the most excellent bash maintainers:
> I have found, what I consider to be a bug, in the following version of
> bash:
> * bash-4.4.23-1.fc28.x86_64
> It is related to this error message:
> * "return: can only `return' from a function or sourced script"

It's not a bug. Bash (and POSIX) make `return' valid only when the shell
is executing a function or sourcing a script.

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.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]