Subject: Re: sh arithmetic expression
To: None <netbsd-users@netbsd.org>
From: Florian Stoehr <netbsd@wolfnode.de>
List: netbsd-users
Date: 12/29/2004 03:14:24
On Tue, 28 Dec 2004, Jason M. Leonard wrote:

>
>
> On Wed, 29 Dec 2004, Florian Stoehr wrote:
>
>> Hi,
>> 
>> the follwing will run with bash, but not with /bin/sh. How to write the 
>> increment statement so that /bin/sh will like it? I played around with 
>> "let" but without success.
>> 
>> #!/bin/sh
>> i=1
>> while [ $i -le $1 ]
>> do
>> 	echo "Run " $i
>> 	i=$[$i+1]  <--- bash can do that, not /bin/sh
>> done
>
> let i=$((i+1))
>
>

Hm ... as I said, I tried that with let and I did it as in sh(1) with 
$((expr)), but it doesn't seem to work:

#!/bin/sh
i=1
while [ $i -le $1 ]
do
 	echo "Run " $i
 	let i=$((i+1))
done


Gives:

flo@irina [/tmp] # ./test.sh 5
Run  1
./test.sh: arith: syntax error: "i+1"

???

-Flo