Greg Wooledge wrote:

On Wed, Apr 11, 2012 at 02:34:01AM -0700, Linda Walsh wrote:
- for ((vl=$((v_level - 1)); $vl > 0; --vl))

The inside of the for ((...)) is already a math context.  You don't need
another $((...)) inside it.

for ((vl = v_level - 1; vl > 0; --vl))

Or is that another "irrelevant detail"?



Um... Why do you think I included it --
I NEVER saw anything like that where [] was used... people
seem to not understand the (()) is arith, but you need $(()) to get
the value out of the insides...



But the examples of use of $(()) are leaning far more toward the perverse side
than simple use of $[]..
a few examples:

- options="$(expr "${options}" : "\(.\{$((${last_option_index}-1))\}\)")"
- YESTERDAY=$(date -r $((`date +%s` - 86400 )) +%d/%m/%Y
- PREGAP=$(($(echo $OFFSETS | cut -f1 -d' ')))

- for ((vl=$((v_level - 1)); $vl > 0; --vl))

---------------------

It's irrelevant to 'function', but not to efficiency or readability.

But hey, gold star for paying attention! ;-)

(those are all examples from various system scripts in /usr...





Reply via email to