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

Re: Setting paths with ~'s in values.



Danny Dulai writes:
 > what is the difference between [[ ... ]] and [ ... ] ?

`[[ ... ]]` is a lexical construct; in effect, `[[` and `]]` are
reserved words (though I don't recall if they're actually implemented
that way).  `[` is just a command that happens to look for an argument
']', and interprets everything in between.

That means that the `...` in a `[[ ... ]]` expression can be treated
specially by the parser, so you can use things like `&&` and `||`
where `[` and `test` require -a and -o.  In particular, the equality
test in a `[[`-expression uses pattern matching, so glob characters
in such expressions are not expanded against the filesystem.  That's
what I've repeatedly been forgetting the last few weeks.

 > Is [[ the builtin version of the test command?

No, `[` is the builtin version of `test`; but many of the conditional
expressions supported by `test` are also supported by `[[ ... ]]`,
which is the source of much of this confusion.



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