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

Re: [PATCH] Re: Parser issues and and [[ $var ]]



On Mon, 12 May 2014 22:01:12 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> This problem already exists -- infix operators that aren't tokens like
> && and || are already lower prececence than prefix operators.  E.g.:
> 
> zsh% [[ -n 1 -eq 1 ]]
> zsh: unknown condition: -n
> 
> So I don't think the patch below changes any of that.

While this sort of thing and the problems with modular conditions are a
real headache for parsing, I don't think the actual practical problems
are anything like as bad.  Almost always real tests use parameters or
quoted expressions (you don't need to know if the literal string -n has
non-zero length), and since [[, unlike [, is parsed before expansion
such tests work fine.  About the only likely exception I can think of is
where someone's used an eval to get an extra level of expansion --- but
that's always a bit hairy.

So having addressed the compatibility issues, perhaps we should restrict
ourselves to tweaking the documentation to mention the problems and how
to keep them at bay.

pws



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