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

Re: grammar



> On 29/04/2026 16:59 BST Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> I was going thru some old stuff and I came across something like this:
>
>  % if [[ $path ]] echo $path
>
>  ... it works, which makes me uncomfortable because it ain't good grammar.

You're basically correct, yes, it's an abbreviation.  Not entirely
logically, it's allowed by the SHORT_LOOPS option.

% if [[ -n string ]] echo string is stringy
string is stringy
% setopt noshortloops
% if [[ -n string ]] echo string is stringy
zsh: parse error near `echo'
% 

If you want to be purist you can turn that off, although of course it
does have other consequences.

pws




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