On 12/09/2010 10:52 AM, Dominic Raferd wrote:
> Description:
>
> $ val=0; let val++; echo $val,$?; unset val
> 1,1
Not a bug.
>
> see the error code 1. Setting any other start value (except undefined)
> for val does not produce this error, the problem occurs for let val++
> and let val-- if the start value is 0.
let intentionally returns status 1 if the value was 0; and status > 1 if
there was an error. Why? So you can do loops such as:
countdown=10
while let countdown--; do ... ; done
> Why does this happen? Is it 'by design'?
Yes. The same as for 'expr' which is standardized by POSIX to have the
same behavior.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc Description: OpenPGP digital signature