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: Fri, 15 Jan 2010 22:34:42 -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

[your repeated attempts at top-posting when you have been advised not to
do so are getting annoying]

According to salih k on 1/15/2010 10:17 PM:
> Hi,
> 
> 1.Linux  2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15 EDT 2008 x86_64
> 2.ksh
> 3.expr version:5.97

Consider upgrading - the latest stable version of coreutils is 8.4.

> 
> Also,
> 1. the exit status coming is 1552 and in some cases 51198.Also In my
> case,the $int_num will have only positive integers.

The exit status CANNOT be larger than 255, since it is strictly limited to
8 bits.  Even if you were getting the result of system() in C code, where
WEXITSTATUS is traditionally bits 15..8 of the 16-bit value, and signals
are accessed via WTERMSIG on bits 7..0, you STILL can't get an exit value
of 1552 or 51198, since those are not multiples of 256.  Please cut and
paste an actual shell transcript in order to demonstrate why you think you
are getting an impossible status; otherwise, I have to suspect that you
are not reporting what you think you are reporting.  We can't help you if
we can't reproduce it.

> 
> So instead of checking exit status not equal to zero for alphanumeric char
> in the file.Shall we directly
> check the exit status -eq 1 or 2 or 3 for the field contain alphanumeric
> charecter.

What exactly are you trying to accomplish?  If all you want to know is
whether $int_num is numeric, you don't even have to use expr.  Something
like this is much faster:

case $int_num in
  *[!0-9]*) echo non-numeric ;;
  *) echo numeric ;;
esac

> 4.Also,if we use if [ $? -ne 0 ] instead of if [ "$?" -ne "0" ] whether this

[ $? -ne 0 ] is strictly equivalent to [ "$?" -ne "0" ] - the shell
removes double-quoting, and neither the expansion of $? nor the literal 0
contain metacharacters that would interfere with how the resulting
argument is handed to [.  You may be better off investing in a good
tutorial book on shell scripting.

-- 
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]