From 26cc1ad1dfb9ba4ffeaf6079762439822ab828ef Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 14 May 2000 22:08:41 +0000 Subject: doc changes; typo in _jobs; integer builtin understands `-i base' --- Doc/Zsh/expn.yo | 74 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 26 deletions(-) (limited to 'Doc/Zsh/expn.yo') diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index bea2888bc..1aa866dff 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1147,6 +1147,14 @@ Matches any number in the range var(x) to var(y), inclusive. Either of the numbers may be omitted to make the range open-ended; hence `tt(<->)' matches any number. To match individual digits, the tt([)...tt(]) form is more efficient. + +Be careful when using other wildcards adjacent to patterns of this form; +for example, tt(<0-9>*) will actually match any number whatsoever at the +start of the string, since the `tt(<0-9>)' will match the first digit, and +the `tt(*)' will match any others. This is a trap for the unwary, but is +in fact an inevitable consequence of the rule that the longest possible +match always succeeds. Expressions such as `tt(<0-9>[^[:digit:]]*)' can be +used instead. ) item(tt(LPAR())...tt(RPAR()))( Matches the enclosed pattern. This is used for grouping. @@ -1355,10 +1363,11 @@ appear on its own: `tt((#s))' and `tt((#e))' are the only valid forms. The `tt((#s))' flag succeeds only at the start of the test string, and the `tt((#e))' flag succeeds only at the end of the test string; they correspond to `tt(^)' and `tt($)' in standard regular expressions. They -are useful for matching path segments in patterns. For example, -`tt(*((#s)|/)test((#e)|/)*)' matches a path segment `tt(test)' in any of -the following strings: tt(test), tt(test/at/start), tt(at/end/test), -tt(in/test/middle). +are useful for matching path segments in patterns other than those in +filename generation (where path segments are in any case treated +separately). For example, `tt(*((#s)|/)test((#e)|/)*)' matches a path +segment `tt(test)' in any of the following strings: tt(test), +tt(test/at/start), tt(at/end/test), tt(in/test/middle). Another use is in parameter substitution; for example `tt(${array/(#s)A*Z(#e)})' will remove only elements of an array which @@ -1449,6 +1458,13 @@ crucial one for establishing whether to use approximation; for example, tt((#a1)abc(#a0)xyz) will not match tt(abcdxyz), because the error occurs at the `tt(x)', where approximation is turned off. +Entire path segments may be matched approximately, so that +`tt((#a1)/foo/d/is/available/at/the/bar)' allows one error in any path +segment. This is much less efficient than without the tt((#a1)), however, +since every directory in the path must be scanned for a possible +approximate match. It is best to place the tt((#a1)) after any path +segments which are known to be correct. + subsect(Recursive Globbing) A pathname component of the form `tt(LPAR())var(foo)tt(/RPAR()#)' matches a path consisting of zero or more directories @@ -1466,10 +1482,11 @@ or example(ls **/bar) does a recursive directory search for files named `tt(bar)' (potentially -including the file `tt(bar)' in the current directory), not following -symbolic links. To follow links, use `tt(***/)'. Neither of these can be -combined with other forms of globbing within the same filename segment; in -that case, the `tt(*)' operators revert to their usual effect. +including the file `tt(bar)' in the current directory). This form does not +follow symbolic links; the alternative form `tt(***/)' does, but is +otherwise identical. Neither of these can be combined with other forms of +globbing within the same path segment; in that case, the `tt(*)' +operators revert to their usual effect. subsect(Glob Qualifiers) cindex(globbing, qualifiers) cindex(qualifiers, globbing) @@ -1484,7 +1501,8 @@ containing no `tt(|)' or `tt(LPAR())' characters (or `tt(~)' if it is special) is taken as a set of glob qualifiers. A glob subexpression that would normally be taken as glob qualifiers, for example `tt((^x))', can be forced to be treated as part of -the glob pattern by doubling the parentheses, for example `tt(((^x)))'. +the glob pattern by doubling the parentheses, in this case producing +`tt(((^x)))'. A qualifier may be any one of the following: @@ -1596,22 +1614,26 @@ permission, and for which other users don't have read or execute permission. ) item(tt(e)var(string))( -The var(string) will be executed and the return value determines if the -filename should be included in the list (if it is zero) or not (if it -is non-zero). The first character after the `tt(e)' will be used as a -separator and anything up to the next matching separator will be taken -as the var(string) (`tt([)', `tt({)', and `tt(<)' match `tt(])', -`tt(})', and `tt(>)' respectively, any other character matches -itself). Note that expansions have to be quoted in the var(string) to -prevent them from being expanded before globbing is done. - -During the execution of var(string) the parameter tt(REPLY) is set to -the filename currently being tested. It may also be set to any string -to make this string be inserted into the list instead of the original -filename. Also, the parameter tt(reply) may be set to an array or a -string and if it is, these strings will be inserted instead of the -value of the tt(REPLY) parameter. For security reasons, tt(reply) -will be unset by the shell before the var(string) is executed. +The var(string) will be executed as shell code. The filename will be +included in the list if and only if the code returns a zero status (usually +the status of the last command). The first character after the `tt(e)' +will be used as a separator and anything up to the next matching separator +will be taken as the var(string); `tt([)', `tt({)', and `tt(<)' match +`tt(])', `tt(})', and `tt(>)', respectively, while any other character +matches itself. Note that expansions must be quoted in the var(string) +to prevent them from being expanded before globbing is done. + +During the execution of var(string) the filename currently being tested is +available in the parameter tt(REPLY); the parameter may be altered to +a string to be inserted into the list instead of the original +filename. In addition, the parameter tt(reply) may be set to an array or a +string, which overrides the value of tt(REPLY). If set to an array, the +latter is inserted into the command line word by word. + +For example, suppose a directory contains a single file `tt(lonely)'. Then +the expression `tt(*(e:'reply=(${REPLY}{1,2})':))' will cause the words +`tt(lonely1 lonely2)' to be inserted into the command line. Note the +quotation marks. ) item(tt(d)var(dev))( files on the device var(dev) @@ -1708,7 +1730,7 @@ order, following any symbolic links. ) item(tt(O)var(c))( like `tt(o)', but sorts in descending order; i.e. `tt(*(^oc))' is the -same as `tt(*(Oc))' and `tt(*(^Oc))' is the same as `tt(*(oc))'; `tt(OD)' +same as `tt(*(Oc))' and `tt(*(^Oc))' is the same as `tt(*(oc))'; `tt(Od)' puts files in the current directory before those in subdirectories at each level of the search. ) -- cgit 1.4.1