expr bug

Jara hugle at vkt.lt
Thu Feb 10 04:51:28 PST 2005


Hello guys.
Recently I had set up the trafic monitoring usign ipfw.
But ofter hour or two it stopped working..

So after some testing I have found a bug, I think
Since all this works only with  Under FreeBSD 4.10 and udner debian.
udner FreeBSD 5.2 and 5.3 I get errors, look :

------------ beggining ----------
#!/bin/bash
test="240 \
0 \
240 \
24535109 \
448241787 \
13385750 \
30655883 \
2428572717 \
30495271 \
29813961 \
4850059 \
240 \
11804353 \
58339445 \
240 \
240 \
2280965"

size=0
for i in $test; do
size=`expr $size + $i`
done
echo "value 1"
echo "$size"

echo " "
size=0
for i in $test; do
size=$(( $size + $i ))
done
echo "value 2"
echo $size

---------- end of script ----------


I get these results under different machines :


Under FreeBSD 4.10-STABLE
./test
value 1
3082976500

value 2
3082976500


Under FreeBSD 5.3 STABLE:
./test
expr: illegal option -- 1
usage: expr [-e] expression
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
value 1


value 2
3082976500



FreeBSD 5.2.1-RELEASE:
./test
expr: illegal option -- 1
usage: expr [-e] expression
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
value 1


value 2
3082976500


Debian with Kernel 2.4
value 1
3082976500

value 2
3082976500


I'm not C++ programmer so I can't look into .c files ...

Hope this helps 

Bye !!!




More information about the freebsd-bugs mailing list