Re: issue with "for name ... [ in word ... ] term do list done"

Phil Pennock <[email protected]>
Newsgroups gmane.comp.shells.zsh.user
Message-ID <[email protected]>
On 2025-06-19 at 04:31 +0200, Vincent Lefevre wrote:
> For instance,
> 
>   for i ab cd ; do do_something_with $i ; done
> 
> in an interactive zsh shell does nothing, while the other shells
> signal a syntax error, which is much more useful.

Well, it does nothing if and only if there's nothing in argv.

% for x y z; echo ". {$x} / {$y} : {$z} ."
% set a b c d e f g h i j k l
% for x y z; echo ". {$x} / {$y} : {$z} ."
. {a} / {b} : {c} .
. {d} / {e} : {f} .
. {g} / {h} : {i} .
. {j} / {k} : {l} .
%

So it's valid and does something useful, iterating in tuples across the
"$@" array.

-Phil
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.