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

Re: Re[2]: why not promote the plague ? (brace|rc|alternative|modern) syntax



On Sat, Dec 14, 2024 at 9:25 PM Mark J. Reed <markjreed@xxxxxxxxx> wrote:
>
>
>
> On Sat, Dec 14, 2024 at 3:11 PM Vadim Zeitlin <vz-zsh@xxxxxxxxxxxx> wrote:
>>
>>
>>  But I think it would make sense to add that there is also the
>>
>>         for var in val1 val2 val3; command
>>
>> syntax which is not covered by any of the options above,
>
>
> Thanks, I did overlook that. It is valid only with SHORT_LOOPS set, and is the only way I know of to use in without also using do.

You can actually mix and match the syntaxes (even without short_loops),
% for var in val1 val2 val3; { echo $var }
val1
val2
val3
% for var (val{1..3}); do echo $var; done
val1
val2
val3

etc. But I probably wouldn't recommend it.

-- 
Mikael Magnusson




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