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

Re: while loop grammar question




On 2024-12-08 15:52, Mark J. Reed wrote:

The brackets are not part of the syntax of the compound statement. Sure,  [, [[, and (( look like syntax – and to be fair, [[ ... ]] and (( ... )) do alter the shell's parsing rules somewhat between the brackets – but they're really just the names of commands, which you can also run at the prompt without any if/while/until anywhere in sight. 

The Gods had their reasons during the creation of the world but IMHO that a command binary should be named '[' strikes me as demented.  Indeed I can find " /usr/bin/[ " but those others are commands too?  Where are they?  But I think I recall Bart saying that '[[' is a zsh internal. 
But the C-style for (( ... ; ... ; ... )) loop is special.

So it seems.  It behaves itself without any of this trouble.  You know, nothing I've yet read -- books, articles, websites -- nothing mentions any of this deep magic.  Anyway I now know to treat 'while' and 'for' very differently which  answers my original question.  Tx. 



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