I understand brackets fairly well, but consider this intentionally flaky code:
alias test {
echo -a a $+ [ $+ b c d e ]
}
this prints:
i'm curious about what's going on which causes the 'b' to dissapear.
Somebody else could explain it better than I, but there are some hard to describe interactions with evaluation brackets and concatenation. However, in practice, the formula that gets used the most looks like this:
a [ $+ [ b ] $+ [ c ] ]
as in
set -e %foo. $+ $cid $+ $chan Hello World.
echo -a %foo. [ $+ [ $cid ] $+ [ $chan ] ]
same as
set -e $+(%,foo.,$cid,$chan) Hello World.
echo -a $($+(%,foo.,$cid,$chan),2)
The [ ] brackets force evaluation of items inside the brackets before items outside of them can be evaluated.
In this case, $+ [ $+ b ] is saying: append b to the $+ outside of [ before it can be evaulated. This results in $+b.
$+anything is treated as $+ (which I think has always been the case).
interesting, thanks khaled.