[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Use expr where possible
From: |
Paul Eggert |
Subject: |
Re: [PATCH] Use expr where possible |
Date: |
Sun, 01 May 2005 22:50:01 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
Stepan Kasal <address@hidden> writes:
> Paul, do you see any problem here?
I don't see any problem in particular, but have you read the caveats about
expr in the Autoconf manual? In particular:
The Posix standard is ambiguous as to whether
@samp{expr 'a' : '\(b\)'} outputs @samp{0} or the empty string.
In practice, it outputs the empty string on most platforms, but portable
scripts should not assume this. For instance, the @acronym{QNX} 4.25 native
@command{expr} returns @samp{0}.
...
Older @command{expr} implementations (e.g., SunOS 4 @command{expr} and
Solaris 8 @command{/usr/ucb/expr}) have a silly length limit that causes
@command{expr} to fail if the matched substring is longer than 120
bytes. In this case, you might want to fall back on @samp{echo|sed} if
@command{expr} fails.
...
The @acronym{QNX} 4.25 @command{expr}, in addition of preferring @samp{0} to
the empty string, has a funny behavior in its exit status: it's always 1
when parentheses are used!