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

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



On Mon, Dec 16, 2024 at 9:29 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>
> On Sat, Dec 14, 2024, at 6:36 PM, Lawrence Velázquez wrote:
> > Other than the `for' variants, none of these (or the short forms
> > below) requires parentheses _per se_.  What they require is that
> > their conditions be, as zshmisc(1) so vaguely puts it, "suitably
> > delimited".  These are all valid:
> >
> >       % if ! ( true ) { print true }
> >       % if [[ x ]] && { false } { print true }
> >       % if true; ! [[ x ]] { print true }
> >       % if print ignored | (( 0 )) { print true }
> >       %
>
> But:
>
>         % if { true } { print true }
>         true
>         % if f() { not executed yet } { print true }
>         true
>         % if () { true } { print true }
>         zsh: parse error near `}'
>
> Anonymous functions accept arguments, so the end of an anonymous
> function _body_ does not delimit the anonymous function _command_.

Here's another confusion to add to the pile (from irc, just now):

18:20:25 <siak> I tried short version of while loop but it didn't work
18:21:12 <siak>  until ollama pull llama3.3; { echo 'oh!';  sleep 3; }
18:22:52 <Mikachu> you need { } around the condition and remove the semicolon
18:22:57 <Mikachu> and then it will also work without shortloops set
18:23:19 <Mikachu> because the condition for a while/until loop can be
a list, it's not clear where you want the condition to end and the
loop body to begin otherwise
18:24:07 <Mikachu> if you reread the "alternate forms for complex
commands" section, you'll notice short_loops only affects commands
with
"sublist", not ones with only "list"
18:24:42 <Mikachu> and that both while and until explicitly say "note
the limitations on the form of list mentioned above."
18:24:48 <llua> the plague~


-- 
Mikael Magnusson




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