diff options
Diffstat (limited to 'Doc/Zsh/cond.yo')
-rw-r--r-- | Doc/Zsh/cond.yo | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/Doc/Zsh/cond.yo b/Doc/Zsh/cond.yo index 9f8a7d820..d04ceb258 100644 --- a/Doc/Zsh/cond.yo +++ b/Doc/Zsh/cond.yo @@ -186,11 +186,44 @@ true if either var(exp1) or var(exp2) is true. ) enditem() +For compatibility, if there is a single argument that is not +syntactically significant, typically a variable, the condition is +treated as a test for whether the expression expands as a string of +non-zero length. In other words, tt([[ $var ]]) is the same as tt([[ -n +$var ]]). It is recommended that the second, explicit, form be used +where possible. + Normal shell expansion is performed on the var(file), var(string) and var(pattern) arguments, but the result of each expansion is constrained to be a single word, similar to the effect of double quotes. -Filename generation is not performed on any form of argument to conditions. -However, pattern metacharacters are active for the var(pattern) arguments; + +Filename generation is not performed on any form of argument to +conditions. However, it can be forced in any case where normal shell +expansion is valid and when the option tt(EXTENDED_GLOB) is in effect by +using an explicit glob qualifier of the form tt(LPAR()#q+RPAR()) at the +end of the string. A normal glob qualifier expression may appear +between the `tt(q)' and the closing parenthesis; if none appears the +expression has no effect beyond causing filename generation. The +results of filename generation are joined together to form a single +word, as with the results of other forms of expansion. + +This special use of filename generation is only available with the +tt([[) syntax. If the condition occurs within the tt([) or tt(test) +builtin commands then globbing occurs instead as part of normal command +line expansion before the condition is evaluated. In this case it may +generate multiple words which are likely to confuse the syntax of the +test command. + +For example, + +tt([[ -n file*(#qN) ]]) + +produces status zero if and only if there is at least one file in the +current directory beginning with the string `tt(file)'. The globbing +qualifier tt(N) ensures that the expression is empty if there is +no matching file. + +Pattern metacharacters are active for the var(pattern) arguments; the patterns are the same as those used for filename generation, see ifzman(\ zmanref(zshexpn)\ |