[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 11:06:50 -0500 |
User-agent: |
KMail/1.11.0 (Linux/2.6.28; KDE/4.2.0; x86_64; ; ) |
On Monday 23 February 2009 10:53:06 Chet Ramey wrote:
> Mike Frysinger wrote:
> > On Monday 23 February 2009 08:48:32 Chet Ramey wrote:
> >> Mike Frysinger wrote:
> >>> previous versions of bash would happily accept negative values (
> >>> treated as a signed integer and masked with like 0xff), but it seems
> >>> some changes related to option parsing has broken that
> >>>
> >>> $ f(){ return -1; }; f
> >>> -bash: return: -1: invalid option
> >>> return: usage: return [n]
> >>
> >> Bash still happily accepts the same negative return values; however, the
> >> `return' builtin was changed to use the standard option parsing rules
> >> like the rest of the builtins. The effect is that arguments
> >> beginning with a `-' that are not to be treated as options must follow
> >> a `--'.
> >
> > that makes negative values kind of useless imo and breaks backwards
> > compatibility. if 'return -1' isnt going to be fixed, then i'd just
> > break it completely so as to force people to migrate to POSIX compliant
> > behavior.
>
> By your logic, nothing could ever be fixed as long as someone was using
> it.
no, by my logic, things behaving *differently from documented/spec* can be
fixed. this falls into neither category and is an arbitrary change with no
gain.
> 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.
> >> It's in the change log as having happened between bash-4.0-alpha and
> >> bash-4.0 beta.
> >
> > the changelog mentions options, not negative values. they arent the same
> > thing.
>
> Ummm...yes, they are. They are both arguments to the command that
> begin with `-'.
if you want to be pedantic, then say return accepts any numeric option and
uses that in place of [n]. or just reject negative values *and document it*.
the 'return' in the bash(1) man page still does not talk about options or --
or anything. that leaves the existing situation a confusing mess for no
reason.
-mike
signature.asc
Description: This is a digitally signed message part.