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

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



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




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