bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in expr***urgent


From: Eric Blake
Subject: Re: Bug in expr***urgent
Date: Mon, 11 Jan 2010 06:17:31 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

According to salih k on 1/10/2010 10:50 PM:
> Hi,
> There is a bug iin the expr command and exit status is"51198" some times
> "1552"

Exit status can never exceed 255 - per POSIX, it is strictly capped at 8
bits to all observers.  I'm not sure where you are getting those numbers.

> I have used expr to check whether the variable is numeric
>        add_num=`expr $int_num + 1 1>/dev/null 2>&1`
>  kms=$?
>        # if [ "$?" -ne "0" ]
>          if [ "$kms" -ne "0" ]
>         then
> here $kms returns exit status other than zero even if $int_num is numeric

That is not a bug.  POSIX requires that expr give an exit status of 1 if
$int_num is the value 0.  Perhaps you want to try:

if [ "$kms" -gt 1 ]

to detect syntactically invalid expressions or command-line errors.

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

Eric Blake             address@hidden

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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