Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: for loop question



On Nov 2, 2014 2:42 PM, "Ray Andrews" <rayandrews@xxxxxxxxxxx> wrote:
>
> But it does show that 'for ((' CAN stop and digest  ' [ -n "$TLC[i]" ] '
if it wants too,
> it just has to make it obscenely difficult. Why can't the truth test of a
command just be taken
> as 'arithmetic' plain and simple?

It's a matter of order-of-evaluation and contextual tokenization.  Once the
parser encounters "for ((" it stops looking for ordinary shell command
tokens and starts looking for math tokens; a word like "test" in that
context is a numeric variable name, not a command name, and "[" has another
meaning as well.  But "$" introduces an expansion in either context, so
$(...) switches back into the regular parsing mode.


Messages sorted by: Reverse Date, Date, Thread, Author