On 3/11/20 11:13 AM, Stephane Chazelas wrote:
> 2020-03-11 09:55:57 -0400, Chet Ramey:
>> On 3/11/20 5:43 AM, Stephane Chazelas wrote:
>>
>>> AFAIK, bash and bosh are the only shells that complain when you
>>> use return outside of functions/sourced scripts (bash also
>>> doesn't exit upon that failing "return" special builtin in that
>>> case which could be seen as a conformance bug). 
>>
>> You really should try posix mode.
> [...]
> 
> As it happens, I did in that case, and I found it behaved the
> same in or outside of POSIX mode:

$ ./bash ./x5
./x5: line 1: return: can only `return' from a function or sourced script
after
$ ./bash -o posix ./x5
./x5: line 1: return: can only `return' from a function or sourced script
$ cat x5
return 7
echo after



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

Reply via email to