Bug 5910 - expr length function fails if argument is single ( or )
expr length function fails if argument is single ( or )
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: sh-utils (Show other bugs)
6.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: bero
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-10-13 13:28 EDT by almquipf
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-10-13 13:28:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description almquipf 1999-10-13 13:28:08 EDT
the gnu utility expr fails in the follow 2 cases:
expr length "("   and   expr length ")"

escaping the ( and ) as '(' ')'  or \(  \) has no effect
expr reports these 2 cases as:  expr: syntax error

readily reproducible from command line

all other single character strings containing all letters
of alphabet in both cases and all other special characters
on standard US keyboard are evaluated correctly by expr
returning correctly a length of 1.

The addition of another character with either ( or )
correctly returns a length of 2 so it does not appear to
be a case of expr requiring balanced parentheses.

Problem first detected on RH6.0 with sh-utils-1.16.23
while using expr in a bash script.

I then upgraded sh-utils-2.0-1 from a rh6.1 distribution
on my rh6.0 machine (upgrade successful, no warning or
errors).  exactly the same results.

here is a test script I wrote to check special characters.
for l in  "~" "!" "@" "#" '$' "%" "^" "&" '*' "(" ")" "_"
"+" "\`" "-" "=" "\\" "|" "," "." "/" "<" ">" "?" "{" "}"
"[" "]"
do
echo -n "$l "
expr length "$l"
done


For what it is worth HP-UX 10.20 expr exhibits the same
behavior.

paul almquist, instructor & sys admin
almquipf@cis.chippewa.tec.wi.us
Comment 1 Bernhard Rosenkraenzer 2002-01-22 07:53:28 EST
According to the base maintainer, this is the expected behavior (and compatible
with pretty much all other unixes).

Note You need to log in before you can comment on or make changes to this bug.