Several forms of complex commands such as loops have alternate forms in zsh. These forms are mostly inspired by the C shell, which was fairly common when zsh was young but has now disappeared. These alternate forms act exactly like the normal forms, they’re just a different syntax. They’re slightly shorter, but less clear.
The standard form for the
for command is
for x in 1 2 3; do echo $x; done, and the standard form for the
while command is
while test …; do somecommand; done.
Ksh, bash and zsh have an alternate form of
for ((i = 0; i < 42; i++)); do somecommand; done, which mimics the
for loops of languages like Pascal or C, to enumerate integers. Other exotic forms that exist in zsh are specific to zsh (but often inspired by csh).
In my usecase I have many font files to patch (i.e. many
.ttf files), and I want to directly type and run the script command in Terminal (not storing it in a script file):
for x in JetBrainsMonoNL* ; do fontforge -script fontpatcher $x --mono -l -q --fontawesome --octicons --fontlogos --mdi --powerline --powerlineextra; done;
The point is:
JetBrainsMonoNL* will be the array to loop through, and if written in the first form:
for x in (JetBrainsMonoNL*)
the parentheses look redundant (at least to me, a newbie), and I think this is why the standard is defined without them.
I was leanring how to create this script and found this question (based on the title), and I think this answer will be helpful for newbie people like me. You can consider this as an real life example for the accepted answer.