bug-bash
[Top][All Lists]
Advanced

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

Re: bash-4.0 regression: negative return values


From: Chet Ramey
Subject: Re: bash-4.0 regression: negative return values
Date: Mon, 23 Feb 2009 15:16:21 -0500
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)

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.

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.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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