[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "return" should not continue script execution, even if used inapprop
From: |
Robert Elz |
Subject: |
Re: "return" should not continue script execution, even if used inappropriately |
Date: |
Mon, 07 Jan 2019 16:15:41 +0700 |
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 ...
The return utility shall cause the shell to stop executing the current
function
or dot script. If the shell is not currently executing a function or
dot script,
the results are unspecified.
That means that bash (or any other shell) can do whatever it likes (but
should document what it does) when a return happens other than in a
function or dot script.
Making it an error is fine, making it == exit is fine, having it set $? and
otherwise do nothing is fine, or simply ignoring it completely is fine.
Amy script that contains "return" must be executed as ". script" for it
to expect anything at all - it is certainly not to be expected that such
a script can be executed as "sh script" (for any 'sh') and do anything
rational at all.
kre
- "return" should not continue script execution, even if used inappropriately, Robert Hailey, 2019/01/05
- Re: "return" should not continue script execution, even if used inappropriately, Chet Ramey, 2019/01/06
- Re: "return" should not continue script execution, even if used inappropriately, Dennis Williamson, 2019/01/06
- Re: "return" should not continue script execution, even if used inappropriately,
Robert Elz <=
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/07
- Re: "return" should not continue script execution, even if used inappropriately, Greg Wooledge, 2019/01/07
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/07
- Re: "return" should not continue script execution, even if used inappropriately, don fong, 2019/01/09
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/10
- Re: "return" should not continue script execution, even if used inappropriately, don fong, 2019/01/20
- Re: "return" should not continue script execution, even if used inappropriately, Greg Wooledge, 2019/01/21
- Re: "return" should not continue script execution, even if used inappropriately, Robert Elz, 2019/01/20