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

Re: Complex forms deprecated?



On Jun 13, 11:11am, Matt Wozniski wrote:
}
} Not to mention that, to me at least, the rules about what can be used
} as the delimiter where are kinda fuzzy.

They're not fuzzy if you really understand the shell grammar.  Confusing,
maybe, but not fuzzy.

} For instance, both
} if {true} {echo good} else {echo bad}
} and
} if (true) {echo good} else {echo bad}
} work, but
} if (true) (echo good) else (echo bad)
} doesn't work...

Braces denote blocks that are executed in the current shell.  Parens
denote blocks that are executed in a forked subshell.  The body of the
if statement has to be a current shell construct, and the conditions
of the if statement have to form a list [in the shell grammar sense
of "list"] of valid shell commands.  The first two both work because
both {true} and (true) are valid shell commands; the last does not
work because (echo good) is not a current shell construct and two
subshells in a row is not a valid list.

Even that is a paraphrase; the deeper reason has to do with "{" being
a "reserved word" in the grammar whereas "(" is merely a token, but it's
easier to follow the reasoning if you think about current vs. subshell.



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