bug-coreutils
[Top][All Lists]
Advanced

[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: Eric Blake
Subject: Re: [coreutils] coreutils-7.0 expr exposes long-standing bug in matlab startup script
Date: Tue, 21 Oct 2008 13:02:16 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Martin Knapp-Cordes on 10/21/2008 8:31 AM:
> Hello,
> 
> I would like to respond to any earlier claim made that
> there is a "long-standing bug in matlab startup script".
> We at the MathWorks disagree.

Unfortunately, your disagreement is due to your misinterpretation of POSIX.

> 
> Please observe the following by reading carefully
> the online documentation for the Open Group Standard,
> UNIX Version 3, expr command. The POSIX standard is
> subsumed under this standard. (IEEE Std 1003.1, 2004
> edition)
> 
> http://www.unix.org/version3
> 
> You will have to sign in to look at the standard.

Several members of this list are also members of the Austin Group,
responsible for the very pages you are quoting.  In particular:

> 
> 1. There are NO options allowed in the expr command.
> 2. A string argument is an argument that cannot be identified
>    as an integer argument or as one of the expression
>    operator symbols ...

http://www.opengroup.org/onlinepubs/009695399/utilities/expr.html

"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)."

> "many scripts out there assume that "expr -1 + 1" evaluates to
> zero."

And coreutils has been patched, so that the next version will once again
restore this behavior, AS AN EXTENSION to POSIX (since no POSIX-conforming
app will ever invoke expr in this manner).

> 
> This is NOT an assumption. It is the REQUIRED behavior in
> order to be a STANDARD conforming shell script.

No, the standard REQUIRES that an application support -- as an argument
separator for all except a small set of exceptions (think echo), and expr
is not in the set of exceptions.  It also REQUIRES that compliant apps use
- -- if they are passing an argument that might be interpreted as an option
by someone that extends the standard.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkj+JzgACgkQ84KuGfSFAYAPUwCfRyQkYBCqWFDNndcpCnx/Sesz
yCoAoKoa4qOB9XXSVXqmbBaUXVn8iYvX
=4Yva
-----END PGP SIGNATURE-----




reply via email to

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