bug-bash
[Top][All Lists]
Advanced

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

Re: bug: return doesn't accept negative numbers


From: Linda Walsh
Subject: Re: bug: return doesn't accept negative numbers
Date: Sun, 07 Aug 2011 17:15:57 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666

Chet Ramey wrote:
On 8/7/11 6:03 PM, Linda Walsh wrote:

Bash itself is inconsistent in that it accepts exit values the same as
every other
program, but limits return values to a particular subset.

Bash accepts any value you want to give to `return' and strips it to
8 bits, as the standard allows.  Read the error message closely: it says
`invalid option'.  return doesn't accept any options
====

        Does 'exit' accept any options?   No.  It doesn't complain.


        I would assert, that 'return', since it accepts no options, cannot
have an 'invalid option', (there are no valid options), therefore, any
argument to should attempt to be parsed as a number.

        Else, I would ask: If -1 is an invalid option, what are valid
options...well, as you said, it accepts no options, so it shouldn't be
possible for it to return a "validation" on the acceptability of something
as an argument -- as the option parser should never be called on it any more
than it is called on exit.

        As a nice enhancement, you could just default to accepting any
expression that returned a number (i.e. treat it as the interior of
a (()), vs. requiring that one use $(((expr))) as is now acceptable,
and explicitly mention that "return $status+0x80" is a bash enhancement...


        Of course to return -1, apparently one can also use
return $(-1)...there are plenty of ways to get around it...
that wasn't the point.

        if shouldn't be trying to parse options any more than 'exit' does.
example of a valid option

        It's not about "getting around the bug" -- it's that it shouldn't
be checking for options in the first place!





reply via email to

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