>
> I thought the $( ) was necessary to make the inner (()) an arithmetic
> expression...  Does it execute in a sub process?
>

No, $( ) is for process substitution, $(( )) is for an arithmetic context.

I normally (in Bash), use (( )) outside the whole expression since it
gives me complete freedom of placement of spacing and eliminates the
need for dollar signs (in most cases). It also makes increment and
similar operators available.

(( arrayA[foo]  =  arrayB[bar] ** 3 / baz ))
(( arrayB[bar]  -=  qux ))
(( qux++ ))

A demonstration of various combinations of spaces and parentheses.

$ echo $(((3+2)))
5
$ echo $(( (3+2) ))
5
$ echo $( ( (3+2) ) )
3+2: command not found

$ echo $( ((3+2)) )

$ echo $((3+2))
5
$ echo $( (3+2) )
3+2: command not found

$ echo $(( 3+2 ))
5
$ echo $(( 3+ 2 ))
5
$ echo $(( 3 + 2 ))
5
$ echo $( 3+2 )
3+2: command not found

--
Visit serverfault.com to get your system administration questions answered.

Reply via email to