On 08/07/2011 02:35 PM, Linda Walsh wrote:


Eric Blake wrote:
On 08/05/2011 05:41 PM, Linda Walsh wrote:
Seem to fail on any negative number, but 'exit status' is defined
as a short int -- not an unsigned value (i.e. -1 would return 255).

In bash, 'return -- -1' sets $? to 255 (note the --). But since that
is already an extension (POSIX does not require 'return' to support --
any more than it is required to support an argument of -1), I agree
with your argument that bash would be more useful if, as an extension
to POSIX, it would handle 'return -1' - in fact, that would match ksh
behavior. Conversely, since portable code already can't use it, it's
no skin off my back if nothing changes here.
---
How about portable code using:

(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.

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to