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 -c 'return; echo "$?"' bash: line 0: return: can only `return' from a function or sourced script 1 $ bash -o posix -c 'return; echo "$?"' bash: line 0: return: can only `return' from a function or sourced script 1 $ bash -c 'printf "%s\n" "$BASH_VERSION"' 5.0.3(1)-release -- Stephane