Bug 5910 - expr length function fails if argument is single ( or )
Summary: expr length function fails if argument is single ( or )
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: sh-utils
Version: 6.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: bero
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-10-13 17:28 UTC by almquipf
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 1999-10-13 17:28:08 UTC
Embargoed:


Attachments (Terms of Use)

Description almquipf 1999-10-13 17:28:08 UTC
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.tec.wi.us

Comment 1 Bernhard Rosenkraenzer 2002-01-22 12:53:28 UTC
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.