[Top][All Lists]

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

Re: bash-4.0 regression: negative return values

From: Mike Frysinger
Subject: Re: bash-4.0 regression: negative return values
Date: Mon, 23 Feb 2009 15:59:36 -0500
User-agent: KMail/1.11.0 (Linux/2.6.28; KDE/4.2.0; x86_64; ; )

On Monday 23 February 2009 15:16:21 Chet Ramey wrote:
> Mike Frysinger wrote:
> >> Are filenames beginning with a `-' useless because `rm' interprets
> >> them as option arguments when, for instance, they're generated by the
> >> expansion of `*'?  Is `rm' broken for interpreting them as options?
> >> I mean, there's no real difference between the two cases.  If you have
> >> an argument that looks like an option, and you don't want it interpreted
> >> as an option, you protect it in some way. The standard way to do that is
> >> to make it follow `--'.
> >
> > we arent talking about rm, nor does 'return' even take any options.
> 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.
> Frankly, exit/logout should be the same way, but existing practice
> has it accepting negative status values, and bash follows that.

i agree that exit/logout/return should operate the same way.  POSIX documents 
them all the same way (unsigned decimal number) and makes no statement about 
negative values.  i dont see how we can argue that return requires people to 
use -- but exit does not ... the things posted in this thread can be flipped 
exactly as reasons for exit still accepting negative values is wrong.

also, if you want to continue saying "negative values are options", what's 
wrong with having return "accept numeric options in place of [n] to return 
negative values" ?

> If it's a documentation problem, how about something like the following
> to replace the introductory text in the SHELL BUILTIN COMMANDS section:
>   Unless otherwise noted, each builtin command documented in this section
>   as accepting options preceded by - accepts -- to signify the end of the
>   options.   The  :, true, false, and test builtins do not accept options
>   and do not treat -- specially.  The exit, logout, break, continue, let,
>   and  shift builtins accept and process arguments beginning with - with-
>   out requiring --.  Other builtins that accept  arguments  but  are  not
>   specified  as accepting options interpret arguments beginning with - as
>   invalid options and require -- to prevent this interpretation.
> That seems to document existing practice.

a good summary introduction, but if return is going to stay broken, it should 
have a note to this section as well.  "See also ....".

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

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