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

Re: `[[ -n $VAR ]]` equal to `[[ $VAR ]]`?

On Thu, Apr 9, 2015 at 7:46 PM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:

> (please don't top post, it's a lot of work to fix the mail before replying)

Please don't lecture others. I hate top posting. I'm 54 and hated the
rising popularity of programs like Outlook which encouraged top posting.
Gmail makes top posting the default. So unless I'm responding to more than
a single point in the original message I take the path of least resistance.
We lost the battle of top versus bottom posting twenty years ago. Move on.

> If you mean ambiguity because VAR might be the string "-z" for
> example, there is no such ambiguity. The syntax of [[ ... ]] is fully
> parsed before any substitutions inside are made (I think, but it's at
> least true for this purpose). (This is unlike [ ... ] which is not
> syntax but a shell builtin that gets passed arguments after they're
> substituted, globbed, expanded and etc).

No, I mean ambiguous in the sense that a naive reader of the script might
wonder what the author intended. Really, there's no good reason to save a
couple of characters in this situation. Be explicit about what you intend
to avoid confusion.

Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

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