[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash-4.0 regression: negative return values

From: Eric Blake
Subject: Re: bash-4.0 regression: negative return values
Date: Mon, 23 Feb 2009 20:49:54 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20081209 Thunderbird/ Mnenhy/

Hash: SHA1

According to Chet Ramey on 2/23/2009 1:16 PM:
> OK.  Let me try to explain how the current behavior derives from Posix.
> It falls under two parts of the standard (section 1.4):
> 1.  Unless otherwise stated in the utility description, when given an
>     option unrecognized by the implementation, or when a required
>     option-argument is not provided, standard utilities shall issue a
>     diagnostic message to standard error and exit with a non-zero exit
>     status.
> 2.  Default Behavior: When this section is listed as "None.", it means
>     that the implementation need not support any options. [...]
> So return doesn't accept any options, and is required to exit when an
> unrecognized option is seen.

However, there is nothing that *requires* that -1 be rejected as an
unknown option.  Consider the case of 'tail -1'.  When textutils 2.0.21
made the change--quoting POSIX as the reason--that users *had* to type
'tail -n -1', there was enough of an uproar that the Austin group ended up
issuing a clarification, making it explicit that while POSIX does not
require support for 'tail -1', it also does not forbid implementations
from providing it as an extension.  Hence, coreutils 5.90 and later now
support, as an extension, the older 'tail -1' syntax in addition to the
POSIX-compliant 'tail -n -1'.

The same argument is worthwhile for exit/return.  Although POSIX does not
require support for any options, neither does it forbid it.  Thus, making
'return -1' behave like 'return 255', as an extension, is still permitted,
and in the interest of backwards-compatibility, is probably also the
nicest thing we can do.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

[Prev in Thread] Current Thread [Next in Thread]