dpk wrote:
> On Fri, 12 Aug 2005, Xu Qiang wrote:
>> 1. The way of incrementing the variable NCOREFILES. Why does it use
>> the formula of "NCOREFILES=$[ $NCOREFILES + 1 ]", and not the direct
>> way of "NCOREFILES=$NCOREFILES+1"?
>
> If that was done, NCOREFILES would end up looking like:
>
> +1+1+1+1+1+1+1
>
> as bash does not automatically differentiate between numeric and
> string variables. What the funky looking construct does is convince
> bash to treat it as a numeric/arithmetic expression.
Strangely, there is no mention of this assignment usage in the book "Learning
the bash shell, 2nd ed" by O'Reilly at my hand. :(
And "man bash" didn't talk of it either. However, it mentioned for arithmetic
evaluation, we can use
id++ id--
variable post-increment and post-decrement
++id --id
variable pre-increment and pre-decrement
If it is correct, then I can also increment NCOREFILES by:
++NCOREFILES.
But I doubt it...
Regards,
Xu Qiang
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"