On 03/05/2012 07:13 AM, Nellis, Kenneth wrote:
> From: Corinna Vinschen
> 
>> Thanks for the review.  Like this?
> 
> If you're open to improvements, the form
>       x=$(($x + 1))
> could arguably be improved with any of the following:
>       x=$((x + 1))

Still POSIX, and supported by /bin/sh (even where /bin/sh is dash)

>       let x=x+1
>       ((x=x+1))
>       ((x++))
>       ((++x))

all bash extensions, so requires /bin/bash.

Also, be careful of ((x++)) - if x starts life 0, then that sets $? to 1.

-- 
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to