diff options
Diffstat (limited to 'doc/glob.n')
-rw-r--r-- | doc/glob.n | 106 |
1 files changed, 62 insertions, 44 deletions
@@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: glob.n,v 1.12.2.1 2004/10/27 12:52:40 dkf Exp $ +'\" RCS: @(#) $Id: glob.n,v 1.22.2.1 2010/09/02 19:50:29 andreas_kupries Exp $ '\" .so man.macros .TH glob n 8.3 Tcl "Tcl Built-In Commands" @@ -19,14 +19,17 @@ glob \- Return names of files that match patterns .SH DESCRIPTION .PP -This command performs file name ``globbing'' in a fashion similar to +This command performs file name +.QW globbing +in a fashion similar to the csh shell. It returns a list of the files whose names match any -of the \fIpattern\fR arguments. +of the \fIpattern\fR arguments. No particular order is guaranteed +in the list, so if a sorted list is required the caller should use +\fBlsort\fR. .LP If the initial arguments to \fBglob\fR start with \fB\-\fR then they are treated as switches. The following switches are currently supported: -.VS 8.3 .TP \fB\-directory\fR \fIdirectory\fR Search for files which match the given patterns starting in the given @@ -37,14 +40,13 @@ characters explicitly. This option may not be used in conjunction with whose names may contain glob-sensitive characters. .TP \fB\-join\fR -The remaining pattern arguments are treated as a single pattern -obtained by joining the arguments with directory separators. -.VE 8.3 +The remaining pattern arguments, after option processing, are treated +as a single pattern obtained by joining the arguments with directory +separators. .TP \fB\-nocomplain\fR Allows an empty list to be returned without error; without this switch an error is returned if the result list would be empty. -.VS 8.3 .TP \fB\-path\fR \fIpathPrefix\fR Search for files with the given \fIpathPrefix\fR where the rest of the name @@ -102,10 +104,10 @@ The following are equivalent: \fBglob */\fR .CE .RE -except that the first case doesn't return the trailing ``/'' and -is more platform independent. +except that the first case doesn't return the trailing +.QW / +and is more platform independent. .RE -.VE 8.3 .TP \fB\-\|\-\fR Marks the end of switches. The argument following this one will @@ -131,20 +133,35 @@ Matches the character \fIx\fR. \fB{\fIa\fB,\fIb\fB,\fI...\fR} Matches any of the strings \fIa\fR, \fIb\fR, etc. .LP -On Unix, as with csh, a ``.'' at the beginning of a file's name or just -after a ``/'' must be matched explicitly or with a {} construct, -unless the ``-types hidden'' flag is given (since ``.'' at the beginning -of a file's name indicates that it is hidden). On other platforms, -files beginning with a ``.'' are handled no differently to any others, -except the special directories ``.'' and ``..'' which must be matched -explicitly (this is to avoid a recursive pattern like ``glob -join * * -* *'' from recursing up the directory hierarchy as well as down). -In addition, all ``/'' characters must be matched explicitly. +On Unix, as with csh, a +.QW . +at the beginning of a file's name or just after a +.QW / +must be matched explicitly or with a {} construct, unless the +\fB\-types hidden\fR flag is given (since +.QW . +at the beginning of a file's name indicates that it is hidden). On +other platforms, files beginning with a +.QW . +are handled no differently to any others, except the special directories +.QW . +and +.QW .. +which must be matched explicitly (this is to avoid a recursive pattern like +.QW "glob -join * * * *" +from recursing up the directory hierarchy as well as down). In addition, all +.QW / +characters must be matched explicitly. .LP -If the first character in a \fIpattern\fR is ``~'' then it refers -to the home directory for the user whose name follows the ``~''. -If the ``~'' is followed immediately by ``/'' then the value of -the HOME environment variable is used. +If the first character in a \fIpattern\fR is +.QW ~ +then it refers to the home directory for the user whose name follows the +.QW ~ . +If the +.QW ~ +is followed immediately by +.QW / +then the value of the HOME environment variable is used. .LP The \fBglob\fR command differs from csh globbing in two ways. First, it does not sort its result list (use the \fBlsort\fR @@ -154,29 +171,32 @@ exist; in csh no check for existence is made unless a pattern contains a ?, *, or [] construct. .LP When the \fBglob\fR command returns relative paths whose filenames -start with a tilde ``~'' (for example through \fBglob *\fR or -\fBglob -tails\fR, the returned list will not quote the tilde with -``./''. This means care must be taken if those names are later to +start with a tilde +.QW ~ +(for example through \fBglob *\fR or \fBglob -tails\fR, the returned +list will not quote the tilde with +.QW ./ . +This means care must be taken if those names are later to be used with \fBfile join\fR, to avoid them being interpreted as absolute paths pointing to a given user's home directory. .SH "PORTABILITY ISSUES" .PP -Unlike other Tcl commands that will accept both network and native -style names (see the \fBfilename\fR manual entry for details on how -native and network names are specified), the \fBglob\fR command only -accepts native names. -.TP \fBWindows\fR . For Windows UNC names, the servername and sharename components of the path may not contain ?, *, or [] constructs. On Windows NT, if \fIpattern\fR is -of the form ``\fB~\fIusername\fB@\fIdomain\fR'' it refers to the home +of the form +.QW \fB~\fIusername\fB@\fIdomain\fR , +it refers to the home directory of the user whose account information resides on the specified NT domain server. Otherwise, user account information is obtained from the local computer. On Windows 95 and 98, \fBglob\fR accepts patterns -like ``.../'' and ``..../'' for successively higher up parent directories. - -. +like +.QW .../ +and +.QW ..../ +for successively higher up parent directories. +.PP Since the backslash character has a special meaning to the glob command, glob patterns containing Windows style path separators need special care. The pattern \fIC:\e\efoo\e\e*\fR is interpreted as @@ -186,13 +206,6 @@ interpreted as a wildcard character. One solution to this problem is to use the Unix style forward slash as a path separator. Windows style paths can be converted to Unix style paths with the command \fBfile join $path\fR (or \fBfile normalize $path\fR in Tcl 8.4). -.TP -\fBMacintosh\fR -. -When using the options, \fB\-directory\fR, \fB\-join\fR or \fB\-path\fR, glob -assumes the directory separator for the entire pattern is the standard -``:''. When not using these options, glob examines each pattern argument -and uses ``/'' unless the pattern contains a ``:''. .SH EXAMPLES Find all the Tcl files in the current directory: .CS @@ -210,7 +223,12 @@ Find all subdirectories of the current directory: \fBglob\fR \-type d * .CE .PP -Find all files whose name contains an "a", a "b" or the sequence "cde": +Find all files whose name contains an +.QW a , +a +.QW b +or the sequence +.QW cde : .CS \fBglob\fR \-type f *{a,b,cde}* .CE |