[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab s
From: |
Pádraig Brady |
Subject: |
Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script |
Date: |
Tue, 14 Oct 2008 15:40:37 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Eric Blake wrote:
> According to Pádraig Brady on 10/14/2008 3:47 AM:
>>> With native versions of expr, and expr from GNU coreutils prior to
>>> version 7.0, the expansion of lscmd usually begins "-rw-r--r--", but
>>> the leading hyphen does not cause the word to be treated as an option.
>> I think that was an unintended change introduced when adding getopt to expr:
>> http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=f65cafd67b33009d23f940968bbe7f9a08d6fe13
>
> Unintended or not, getopt's side effect of complaining about unrecognized
> options is necessary for standard compliance (ie. all earlier versions of
> coreutils had a bug in this area), so we should not revert it.
Quoting the spec:
"Also note that this volume of IEEE Std 1003.1-2001 permits implementations to
extend utilities.
The expr utility permits the integer arguments to be preceded with a unary
minus. This means that
an integer argument could look like an option. Therefore, the conforming
application must employ
the "--" construct of Guideline 10 of the Base Definitions volume of IEEE Std
1003.1-2001,
Section 12.2, Utility Syntax Guidelines to protect its operands if there is any
chance the
first operand might be a negative integer (or any string with a leading minus)."
Does the above mean expr must support -- or that apps must use --
I think it's the former, and this is what the expr code tries to do.
I.E. it does try to treat non options starting with - as part of the expression.
However it gets it wrong in the case of chained short args as seen here:
localhost:~/git/coreutils/src$ expr -oh : -oh
3
localhost:~/git/coreutils/src$ expr -- -oh : -oh
3
localhost:~/git/coreutils/src$ ./expr-new -oh : -oh
./expr: syntax error
localhost:~/git/coreutils/src$ ./expr-new -o : -o
2
localhost:~/git/coreutils/src$ ./expr-new -- -oh : -oh
3
cheers,
Pádraig.
p.s. why does expr need the --bignum option anyway?
Shouldn't we just use it by default if available.
- [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Nelson H. F. Beebe, 2008/10/13
- Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Bob Proulx, 2008/10/13
- Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Pádraig Brady, 2008/10/14
- Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Paul Eggert, 2008/10/15
- Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Jim Meyering, 2008/10/15
- Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Pádraig Brady, 2008/10/15
- Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Jim Meyering, 2008/10/15
- [PATCH] Add option processing tests for 'expr', Pádraig Brady, 2008/10/15
- Re: [PATCH] Add option processing tests for 'expr', Jim Meyering, 2008/10/15
- Re: [PATCH] Add option processing tests for 'expr', James Youngman, 2008/10/19
Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Jim Meyering, 2008/10/15
Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script, Pádraig Brady, 2008/10/16