Eric Blake wrote:
(exit -1); return

That's not portable, either. exit is allowed to reject -1 as invalid. POSIX is clear that exit and return have the same constraints - if an argument is provided, it must be 0-255 to be portable.

However, you are on to something - since bash allows 'exit -1' as an extension, it should similarly allow 'return -1' as the same sort of extension. The fact that bash accepts 'exit -1' and 'exit -- -1', but only 'return -- -1', is the real point that you are complaining about.

----
        Clearly(? :-)), 'return' should accept -1, in 'normal mode',
and both 'exit' and 'return' should return error "ERANGE" if "--posix" is
set, and -1 is given.  Iinvalid option doesn't make as much sense, in
this situtation, if it was -k or -m, sure...but in this case, it's a fact
that --posix artificially limits exit values apart from what is allowed in
most prog langs (which accept negative, but still return results &0xff),
so for Posix, it's a matter of disallowing a 'normal range', vs. it being
an invalid option....

        Would that be sound reasoning?





Reply via email to