xref: /freebsd/contrib/tcsh/glob.3 (revision 9122aeeaa60ee2a1381ea935d749194b32940e7a)
1*cc698b49SBrooks Davis.\"	NetBSD: glob.3,v 1.17 2001/03/16 21:09:05 christos Exp
26767bd61SMark Peek.\"
36767bd61SMark Peek.\" Copyright (c) 1989, 1991, 1993, 1994
46767bd61SMark Peek.\"	The Regents of the University of California.  All rights reserved.
5c80476e4SDavid E. O'Brien.\"
6c80476e4SDavid E. O'Brien.\" This code is derived from software contributed to Berkeley by
7c80476e4SDavid E. O'Brien.\" Guido van Rossum.
86767bd61SMark Peek.\" Redistribution and use in source and binary forms, with or without
96767bd61SMark Peek.\" modification, are permitted provided that the following conditions
106767bd61SMark Peek.\" are met:
116767bd61SMark Peek.\" 1. Redistributions of source code must retain the above copyright
126767bd61SMark Peek.\"    notice, this list of conditions and the following disclaimer.
136767bd61SMark Peek.\" 2. Redistributions in binary form must reproduce the above copyright
146767bd61SMark Peek.\"    notice, this list of conditions and the following disclaimer in the
156767bd61SMark Peek.\"    documentation and/or other materials provided with the distribution.
1629301572SMark Peek.\" 3. Neither the name of the University nor the names of its contributors
176767bd61SMark Peek.\"    may be used to endorse or promote products derived from this software
186767bd61SMark Peek.\"    without specific prior written permission.
19c80476e4SDavid E. O'Brien.\"
206767bd61SMark Peek.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
216767bd61SMark Peek.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226767bd61SMark Peek.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
236767bd61SMark Peek.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
246767bd61SMark Peek.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
256767bd61SMark Peek.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
266767bd61SMark Peek.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
276767bd61SMark Peek.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
286767bd61SMark Peek.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
296767bd61SMark Peek.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
306767bd61SMark Peek.\" SUCH DAMAGE.
31c80476e4SDavid E. O'Brien.\"
326767bd61SMark Peek.\"     @(#)glob.3	8.3 (Berkeley) 4/16/94
33c80476e4SDavid E. O'Brien.\"
346767bd61SMark Peek.Dd March 31, 1998
356767bd61SMark Peek.Dt GLOB 3
366767bd61SMark Peek.Os
376767bd61SMark Peek.Sh NAME
386767bd61SMark Peek.Nm glob ,
396767bd61SMark Peek.Nm globfree
406767bd61SMark Peek.Nd generate pathnames matching a pattern
416767bd61SMark Peek.Sh LIBRARY
426767bd61SMark Peek.Lb libc
436767bd61SMark Peek.Sh SYNOPSIS
446767bd61SMark Peek.Fd #include <glob.h>
456767bd61SMark Peek.Ft int
466767bd61SMark Peek.Fn glob "const char *pattern" "int flags" "const int (*errfunc)(const char *, int)" "glob_t *pglob"
476767bd61SMark Peek.Ft void
486767bd61SMark Peek.Fn globfree "glob_t *pglob"
496767bd61SMark Peek.Sh DESCRIPTION
506767bd61SMark PeekThe
516767bd61SMark Peek.Fn glob
526767bd61SMark Peekfunction
53c80476e4SDavid E. O'Brienis a pathname generator that implements the rules for file name pattern
54c80476e4SDavid E. O'Brienmatching used by the shell.
556767bd61SMark Peek.Pp
56c80476e4SDavid E. O'BrienThe include file
576767bd61SMark Peek.Pa glob.h
58c80476e4SDavid E. O'Briendefines the structure type
596767bd61SMark Peek.Fa glob_t ,
60c80476e4SDavid E. O'Brienwhich contains at least the following fields:
616767bd61SMark Peek.Bd -literal
62c80476e4SDavid E. O'Brientypedef struct {
63c80476e4SDavid E. O'Brien	int gl_pathc;		/* count of total paths so far */
64c80476e4SDavid E. O'Brien	int gl_matchc;		/* count of paths matching pattern */
65c80476e4SDavid E. O'Brien	int gl_offs;		/* reserved at beginning of gl_pathv */
66c80476e4SDavid E. O'Brien	int gl_flags;		/* returned flags */
67c80476e4SDavid E. O'Brien	char **gl_pathv;	/* list of paths matching pattern */
68c80476e4SDavid E. O'Brien} glob_t;
696767bd61SMark Peek.Ed
706767bd61SMark Peek.Pp
71c80476e4SDavid E. O'BrienThe argument
726767bd61SMark Peek.Fa pattern
73c80476e4SDavid E. O'Brienis a pointer to a pathname pattern to be expanded.
746767bd61SMark PeekThe
756767bd61SMark Peek.Fn glob
766767bd61SMark Peekargument
77c80476e4SDavid E. O'Brienmatches all accessible pathnames against the pattern and creates
78c80476e4SDavid E. O'Briena list of the pathnames that match.
79c80476e4SDavid E. O'BrienIn order to have access to a pathname,
806767bd61SMark Peek.Fn glob
81c80476e4SDavid E. O'Brienrequires search permission on every component of a path except the last
82c80476e4SDavid E. O'Brienand read permission on each directory of any filename component of
836767bd61SMark Peek.Fa pattern
846767bd61SMark Peekthat contains any of the special characters
856767bd61SMark Peek.Ql * ,
866767bd61SMark Peek.Ql ?
876767bd61SMark Peekor
886767bd61SMark Peek.Ql [ .
896767bd61SMark Peek.Pp
906767bd61SMark PeekThe
916767bd61SMark Peek.Fn glob
926767bd61SMark Peekargument
93c80476e4SDavid E. O'Brienstores the number of matched pathnames into the
946767bd61SMark Peek.Fa gl_pathc
95c80476e4SDavid E. O'Brienfield, and a pointer to a list of pointers to pathnames into the
966767bd61SMark Peek.Fa gl_pathv
97c80476e4SDavid E. O'Brienfield.
986767bd61SMark PeekThe first pointer after the last pathname is
996767bd61SMark Peek.Dv NULL .
100c80476e4SDavid E. O'BrienIf the pattern does not match any pathnames, the returned number of
101c80476e4SDavid E. O'Brienmatched paths is set to zero.
1026767bd61SMark Peek.Pp
103c80476e4SDavid E. O'BrienIt is the caller's responsibility to create the structure pointed to by
1046767bd61SMark Peek.Fa pglob .
105c80476e4SDavid E. O'BrienThe
1066767bd61SMark Peek.Fn glob
107c80476e4SDavid E. O'Brienfunction allocates other space as needed, including the memory pointed
108c80476e4SDavid E. O'Briento by
1096767bd61SMark Peek.Fa gl_pathv .
1106767bd61SMark Peek.Pp
111c80476e4SDavid E. O'BrienThe argument
1126767bd61SMark Peek.Fa flags
113c80476e4SDavid E. O'Brienis used to modify the behavior of
1146767bd61SMark Peek.Fn glob .
115c80476e4SDavid E. O'BrienThe value of
1166767bd61SMark Peek.Fa flags
1176767bd61SMark Peekis the bitwise inclusive
1186767bd61SMark Peek.Tn OR
1196767bd61SMark Peekof any of the following
120c80476e4SDavid E. O'Brienvalues defined in
1216767bd61SMark Peek.Pa glob.h :
1226767bd61SMark Peek.Bl -tag -width GLOB_ALTDIRFUNC
1236767bd61SMark Peek.It Dv GLOB_APPEND
124c80476e4SDavid E. O'BrienAppend pathnames generated to the ones from a previous call (or calls)
125c80476e4SDavid E. O'Briento
1266767bd61SMark Peek.Fn glob .
127c80476e4SDavid E. O'BrienThe value of
1286767bd61SMark Peek.Fa gl_pathc
129c80476e4SDavid E. O'Brienwill be the total matches found by this call and the previous call(s).
130c80476e4SDavid E. O'BrienThe pathnames are appended to, not merged with the pathnames returned by
131c80476e4SDavid E. O'Brienthe previous call(s).
132c80476e4SDavid E. O'BrienBetween calls, the caller must not change the setting of the
1336767bd61SMark Peek.Dv GLOB_DOOFFS
1346767bd61SMark Peekflag, nor change the value of
1356767bd61SMark Peek.Fa gl_offs
136c80476e4SDavid E. O'Brienwhen
1376767bd61SMark Peek.Dv GLOB_DOOFFS
1386767bd61SMark Peekis set, nor (obviously) call
1396767bd61SMark Peek.Fn globfree
140c80476e4SDavid E. O'Brienfor
1416767bd61SMark Peek.Fa pglob .
1426767bd61SMark Peek.It Dv GLOB_DOOFFS
143c80476e4SDavid E. O'BrienMake use of the
1446767bd61SMark Peek.Fa gl_offs
145c80476e4SDavid E. O'Brienfield.
146c80476e4SDavid E. O'BrienIf this flag is set,
1476767bd61SMark Peek.Fa gl_offs
1486767bd61SMark Peekis used to specify how many
1496767bd61SMark Peek.Dv NULL
1506767bd61SMark Peekpointers to prepend to the beginning
151c80476e4SDavid E. O'Brienof the
1526767bd61SMark Peek.Fa gl_pathv
153c80476e4SDavid E. O'Brienfield.
154c80476e4SDavid E. O'BrienIn other words,
1556767bd61SMark Peek.Fa gl_pathv
156c80476e4SDavid E. O'Brienwill point to
1576767bd61SMark Peek.Fa gl_offs
1586767bd61SMark Peek.Dv NULL
1596767bd61SMark Peekpointers,
160c80476e4SDavid E. O'Brienfollowed by
1616767bd61SMark Peek.Fa gl_pathc
1626767bd61SMark Peekpathname pointers, followed by a
1636767bd61SMark Peek.Dv NULL
1646767bd61SMark Peekpointer.
1656767bd61SMark Peek.It Dv GLOB_ERR
166c80476e4SDavid E. O'BrienCauses
1676767bd61SMark Peek.Fn glob
168c80476e4SDavid E. O'Briento return when it encounters a directory that it cannot open or read.
169c80476e4SDavid E. O'BrienOrdinarily,
1706767bd61SMark Peek.Fn glob
171c80476e4SDavid E. O'Briencontinues to find matches.
1726767bd61SMark Peek.It Dv GLOB_MARK
173c80476e4SDavid E. O'BrienEach pathname that is a directory that matches
1746767bd61SMark Peek.Fa pattern
175c80476e4SDavid E. O'Brienhas a slash
176c80476e4SDavid E. O'Brienappended.
1776767bd61SMark Peek.It Dv GLOB_NOCHECK
178c80476e4SDavid E. O'BrienIf
1796767bd61SMark Peek.Fa pattern
180c80476e4SDavid E. O'Briendoes not match any pathname, then
1816767bd61SMark Peek.Fn glob
182c80476e4SDavid E. O'Brienreturns a list
183c80476e4SDavid E. O'Brienconsisting of only
1846767bd61SMark Peek.Fa pattern ,
185c80476e4SDavid E. O'Brienwith the number of total pathnames is set to 1, and the number of matched
186c80476e4SDavid E. O'Brienpathnames set to 0.
1876767bd61SMark Peek.It Dv GLOB_NOSORT
1886767bd61SMark PeekBy default, the pathnames are sorted in ascending
1896767bd61SMark Peek.Tn ASCII
1906767bd61SMark Peekorder;
1916767bd61SMark Peekthis flag prevents that sorting (speeding up
1926767bd61SMark Peek.Fn glob ) .
1936767bd61SMark Peek.El
1946767bd61SMark Peek.Pp
1956767bd61SMark PeekThe following values may also be included in
1966767bd61SMark Peek.Fa flags ,
1976767bd61SMark Peekhowever, they are non-standard extensions to
1986767bd61SMark Peek.St -p1003.2 .
1996767bd61SMark Peek.Bl -tag -width GLOB_ALTDIRFUNC
2006767bd61SMark Peek.It Dv GLOB_ALTDIRFUNC
2016767bd61SMark PeekThe following additional fields in the pglob structure have been
2026767bd61SMark Peekinitialized with alternate functions for glob to use to open, read,
2036767bd61SMark Peekand close directories and to get stat information on names found
2046767bd61SMark Peekin those directories.
2056767bd61SMark Peek.Bd -literal
2066767bd61SMark Peek	void *(*gl_opendir)(const char * name);
2076767bd61SMark Peek	struct dirent *(*gl_readdir)(void *);
2086767bd61SMark Peek	void (*gl_closedir)(void *);
2096767bd61SMark Peek	int (*gl_lstat)(const char *name, struct stat *st);
2106767bd61SMark Peek	int (*gl_stat)(const char *name, struct stat *st);
2116767bd61SMark Peek.Ed
2126767bd61SMark Peek.Pp
2136767bd61SMark PeekThis extension is provided to allow programs such as
2146767bd61SMark Peek.Xr restore 8
2156767bd61SMark Peekto provide globbing from directories stored on tape.
2166767bd61SMark Peek.It Dv GLOB_BRACE
2176767bd61SMark PeekPre-process the pattern string to expand
2186767bd61SMark Peek.Ql {pat,pat,...}
2196767bd61SMark Peekstrings like
2206767bd61SMark Peek.Xr csh 1 .
2216767bd61SMark PeekThe pattern
2226767bd61SMark Peek.Ql {}
2236767bd61SMark Peekis left unexpanded for historical reasons
2246767bd61SMark Peek.Po
2256767bd61SMark Peek.Xr csh 1
2266767bd61SMark Peekdoes the same thing to ease typing of
2276767bd61SMark Peek.Xr find 1
2286767bd61SMark Peekpatterns
2296767bd61SMark Peek.Pc .
2306767bd61SMark Peek.It Dv GLOB_MAGCHAR
2316767bd61SMark PeekSet by the
2326767bd61SMark Peek.Fn glob
2336767bd61SMark Peekfunction if the pattern included globbing characters.
2346767bd61SMark PeekSee the description of the usage of the
2356767bd61SMark Peek.Fa gl_matchc
2366767bd61SMark Peekstructure member for more details.
2376767bd61SMark Peek.It Dv GLOB_NOMAGIC
2386767bd61SMark PeekIs the same as
2396767bd61SMark Peek.Dv GLOB_NOCHECK
2406767bd61SMark Peekbut it only appends the
2416767bd61SMark Peek.Fa pattern
242c80476e4SDavid E. O'Brienif it does not contain any of the special characters ``*'', ``?'' or ``[''.
2436767bd61SMark Peek.Dv GLOB_NOMAGIC
2446767bd61SMark Peekis provided to simplify implementing the historic
2456767bd61SMark Peek.Xr csh 1
2466767bd61SMark Peekglobbing behavior and should probably not be used anywhere else.
2476767bd61SMark Peek.It Dv GLOB_NOESCAPE
2486767bd61SMark PeekDisable the use of the backslash
2496767bd61SMark Peek.Pq Ql \e
2506767bd61SMark Peekcharacter for quoting.
2516767bd61SMark Peek.It Dv GLOB_TILDE
2526767bd61SMark PeekExpand patterns that start with
2536767bd61SMark Peek.Ql ~
2546767bd61SMark Peekto user name home directories.
2556767bd61SMark Peek.It Dv GLOB_LIMIT
2566767bd61SMark PeekLimit the amount of memory used by matches to
2576767bd61SMark Peek.Li ARG_MAX
2586767bd61SMark PeekThis option should be set for programs that can be coerced to a denial of
2596767bd61SMark Peekservice attack via patterns that expand to a very large number of matches,
2606767bd61SMark Peeksuch as a long string of
2616767bd61SMark Peek.Li */../*/..
2626767bd61SMark Peek.El
2636767bd61SMark Peek.Pp
264c80476e4SDavid E. O'BrienIf, during the search, a directory is encountered that cannot be opened
265c80476e4SDavid E. O'Brienor read and
2666767bd61SMark Peek.Fa errfunc
2676767bd61SMark Peekis
2686767bd61SMark Peek.Pf non- Dv NULL ,
2696767bd61SMark Peek.Fn glob
2706767bd61SMark Peekcalls
2716767bd61SMark Peek.Fa (*errfunc)(path, errno) .
2726767bd61SMark PeekThis may be unintuitive: a pattern like
2736767bd61SMark Peek.Ql */Makefile
2746767bd61SMark Peekwill try to
2756767bd61SMark Peek.Xr stat 2
2766767bd61SMark Peek.Ql foo/Makefile
2776767bd61SMark Peekeven if
2786767bd61SMark Peek.Ql foo
2796767bd61SMark Peekis not a directory, resulting in a
280c80476e4SDavid E. O'Briencall to
2816767bd61SMark Peek.Fa errfunc .
2826767bd61SMark PeekThe error routine can suppress this action by testing for
2836767bd61SMark Peek.Dv ENOENT
284c80476e4SDavid E. O'Brienand
2856767bd61SMark Peek.Dv ENOTDIR ;
2866767bd61SMark Peekhowever, the
2876767bd61SMark Peek.Dv GLOB_ERR
2886767bd61SMark Peekflag will still cause an immediate
2896767bd61SMark Peekreturn when this happens.
2906767bd61SMark Peek.Pp
2916767bd61SMark PeekIf
2926767bd61SMark Peek.Fa errfunc
2936767bd61SMark Peekreturns non-zero,
2946767bd61SMark Peek.Fn glob
2956767bd61SMark Peekstops the scan and returns
2966767bd61SMark Peek.Dv GLOB_ABORTED
2976767bd61SMark Peekafter setting
2986767bd61SMark Peek.Fa gl_pathc
2996767bd61SMark Peekand
3006767bd61SMark Peek.Fa gl_pathv
301c80476e4SDavid E. O'Briento reflect any paths already matched.
302c80476e4SDavid E. O'BrienThis also happens if an error is encountered and
3036767bd61SMark Peek.Dv GLOB_ERR
304c80476e4SDavid E. O'Brienis set in
3056767bd61SMark Peek.Fa flags ,
306c80476e4SDavid E. O'Brienregardless of the return value of
3076767bd61SMark Peek.Fa errfunc ,
308c80476e4SDavid E. O'Brienif called.
309c80476e4SDavid E. O'BrienIf
3106767bd61SMark Peek.Dv GLOB_ERR
311c80476e4SDavid E. O'Brienis not set and either
3126767bd61SMark Peek.Fa errfunc
3136767bd61SMark Peekis
3146767bd61SMark Peek.Dv NULL
3156767bd61SMark Peekor
3166767bd61SMark Peek.Fa errfunc
317c80476e4SDavid E. O'Brienreturns zero, the error is ignored.
3186767bd61SMark Peek.Pp
319c80476e4SDavid E. O'BrienThe
3206767bd61SMark Peek.Fn globfree
321c80476e4SDavid E. O'Brienfunction frees any space associated with
3226767bd61SMark Peek.Fa pglob
323c80476e4SDavid E. O'Brienfrom a previous call(s) to
3246767bd61SMark Peek.Fn glob .
3256767bd61SMark Peek.Pp
3266767bd61SMark PeekThe historical
3276767bd61SMark Peek.Dv GLOB_QUOTE
3286767bd61SMark Peekflag is no longer supported.
3296767bd61SMark PeekPer
3306767bd61SMark Peek.St -p1003.2-92 ,
3316767bd61SMark Peekbackslash escaping of special characters is the default behaviour;
3326767bd61SMark Peekit may be disabled by specifying the
3336767bd61SMark Peek.Dv GLOB_NOESCAPE
3346767bd61SMark Peekflag.
3356767bd61SMark Peek.Sh RETURN VALUES
336c80476e4SDavid E. O'BrienOn successful completion,
3376767bd61SMark Peek.Fn glob
338c80476e4SDavid E. O'Brienreturns zero.
339c80476e4SDavid E. O'BrienIn addition the fields of
3406767bd61SMark Peek.Fa pglob
341c80476e4SDavid E. O'Briencontain the values described below:
3426767bd61SMark Peek.Bl -tag -width GLOB_NOCHECK
3436767bd61SMark Peek.It Fa gl_pathc
344c80476e4SDavid E. O'Briencontains the total number of matched pathnames so far.
345c80476e4SDavid E. O'BrienThis includes other matches from previous invocations of
3466767bd61SMark Peek.Fn glob
347c80476e4SDavid E. O'Brienif
3486767bd61SMark Peek.Dv GLOB_APPEND
349c80476e4SDavid E. O'Brienwas specified.
3506767bd61SMark Peek.It Fa gl_matchc
351c80476e4SDavid E. O'Briencontains the number of matched pathnames in the current invocation of
3526767bd61SMark Peek.Fn glob .
3536767bd61SMark Peek.It Fa gl_flags
354c80476e4SDavid E. O'Briencontains a copy of the
3556767bd61SMark Peek.Fa flags
3566767bd61SMark Peekparameter with the bit
3576767bd61SMark Peek.Dv GLOB_MAGCHAR
3586767bd61SMark Peekset if
3596767bd61SMark Peek.Fa pattern
360c80476e4SDavid E. O'Briencontained any of the special characters ``*'', ``?'' or ``['', cleared
361c80476e4SDavid E. O'Brienif not.
3626767bd61SMark Peek.It Fa gl_pathv
3636767bd61SMark Peekcontains a pointer to a
3646767bd61SMark Peek.Dv NULL Ns -terminated
3656767bd61SMark Peeklist of matched pathnames.
366c80476e4SDavid E. O'BrienHowever, if
3676767bd61SMark Peek.Fa gl_pathc
368c80476e4SDavid E. O'Brienis zero, the contents of
3696767bd61SMark Peek.Fa gl_pathv
370c80476e4SDavid E. O'Brienare undefined.
3716767bd61SMark Peek.El
3726767bd61SMark Peek.Pp
373c80476e4SDavid E. O'BrienIf
3746767bd61SMark Peek.Fn glob
3756767bd61SMark Peekterminates due to an error, it sets
3766767bd61SMark Peek.Va errno
3776767bd61SMark Peekand returns one of the following non-zero constants, which are defined
3786767bd61SMark Peekin the include file
3796767bd61SMark Peek.Aq Pa glob.h :
3806767bd61SMark Peek.Bl -tag -width GLOB_ABORTEDXXX
3816767bd61SMark Peek.It Dv GLOB_ABORTED
382c80476e4SDavid E. O'BrienThe scan was stopped because an error was encountered and either
3836767bd61SMark Peek.Dv GLOB_ERR
3846767bd61SMark Peekwas set or
3856767bd61SMark Peek.Fa (*errfunc)()
3866767bd61SMark Peekreturned non-zero.
3876767bd61SMark Peek.It Dv GLOB_NOMATCH
3886767bd61SMark PeekThe pattern does not match any existing pathname, and
3896767bd61SMark Peek.Dv GLOB_NOCHECK
3906767bd61SMark Peekwas not set int
3916767bd61SMark Peek.Dv flags .
3926767bd61SMark Peek.It Dv GLOB_NOSPACE
3936767bd61SMark PeekAn attempt to allocate memory failed, or if
3946767bd61SMark Peek.Va errno
3956767bd61SMark Peekwas 0
3966767bd61SMark Peek.Li GLOB_LIMIT
3976767bd61SMark Peekwas specified in the flags and
3986767bd61SMark Peek.Li ARG_MAX
3996767bd61SMark Peekpatterns were matched.
4006767bd61SMark Peek.El
4016767bd61SMark Peek.Pp
4026767bd61SMark PeekThe historical
4036767bd61SMark Peek.Dv GLOB_ABEND
4046767bd61SMark Peekreturn constant is no longer supported.  Portable applications should use the
4056767bd61SMark Peek.Dv GLOB_ABORTED
4066767bd61SMark Peekconstant instead.
4076767bd61SMark Peek.Pp
408c80476e4SDavid E. O'BrienThe arguments
4096767bd61SMark Peek.Fa pglob\->gl_pathc
410c80476e4SDavid E. O'Brienand
4116767bd61SMark Peek.Fa pglob\->gl_pathv
412c80476e4SDavid E. O'Brienare still set as specified above.
4136767bd61SMark Peek.Sh ENVIRONMENT
4146767bd61SMark Peek.Bl -tag -width HOME -compact
4156767bd61SMark Peek.It Ev HOME
4166767bd61SMark PeekIf defined, used as the home directory of the current user in
4176767bd61SMark Peektilde expansions.
4186767bd61SMark Peek.El
4196767bd61SMark Peek.Sh EXAMPLE
4206767bd61SMark PeekA rough equivalent of
4216767bd61SMark Peek.Ql "ls -l *.c *.h"
4226767bd61SMark Peekcan be obtained with the
423c80476e4SDavid E. O'Brienfollowing code:
4246767bd61SMark Peek.Bd -literal -offset indent
425c80476e4SDavid E. O'Brienglob_t g;
426c80476e4SDavid E. O'Brien
427c80476e4SDavid E. O'Brieng.gl_offs = 2;
428c80476e4SDavid E. O'Brienglob("*.c", GLOB_DOOFFS, NULL, &g);
429c80476e4SDavid E. O'Brienglob("*.h", GLOB_DOOFFS | GLOB_APPEND, NULL, &g);
430c80476e4SDavid E. O'Brieng.gl_pathv[0] = "ls";
431c80476e4SDavid E. O'Brieng.gl_pathv[1] = "-l";
432c80476e4SDavid E. O'Brienexecvp("ls", g.gl_pathv);
4336767bd61SMark Peek.Ed
4346767bd61SMark Peek.Sh SEE ALSO
4356767bd61SMark Peek.Xr sh 1 ,
4366767bd61SMark Peek.Xr fnmatch 3 ,
4376767bd61SMark Peek.Xr regexp 3
4386767bd61SMark Peek.Sh STANDARDS
4396767bd61SMark PeekThe
4406767bd61SMark Peek.Fn glob
4416767bd61SMark Peekfunction is expected to be
4426767bd61SMark Peek.St -p1003.2
4436767bd61SMark Peekcompatible with the exception
4446767bd61SMark Peekthat the flags
4456767bd61SMark Peek.Dv GLOB_ALTDIRFUNC,
4466767bd61SMark Peek.Dv GLOB_BRACE
4476767bd61SMark Peek.Dv GLOB_MAGCHAR,
4486767bd61SMark Peek.Dv GLOB_NOMAGIC,
4496767bd61SMark Peek.Dv GLOB_TILDE,
450c80476e4SDavid E. O'Brienand
4516767bd61SMark Peek.Dv GLOB_LIMIT
4526767bd61SMark Peekand the fields
4536767bd61SMark Peek.Fa gl_matchc
4546767bd61SMark Peekand
4556767bd61SMark Peek.Fa gl_flags
4566767bd61SMark Peekshould not be used by applications striving for strict
4576767bd61SMark Peek.Tn POSIX
4586767bd61SMark Peekconformance.
4596767bd61SMark Peek.Sh HISTORY
4606767bd61SMark PeekThe
4616767bd61SMark Peek.Fn glob
4626767bd61SMark Peekand
4636767bd61SMark Peek.Fn globfree
4646767bd61SMark Peekfunctions first appeared in
4656767bd61SMark Peek.Bx 4.4 .
4666767bd61SMark Peek.Sh BUGS
4676767bd61SMark PeekPatterns longer than
4686767bd61SMark Peek.Dv MAXPATHLEN
4696767bd61SMark Peekmay cause unchecked errors.
4706767bd61SMark Peek.Pp
4716767bd61SMark PeekThe
4726767bd61SMark Peek.Fn glob
4736767bd61SMark Peekfunction may fail and set
4746767bd61SMark Peek.Va errno
4756767bd61SMark Peekfor any of the errors specified for the library routines
4766767bd61SMark Peek.Xr stat 2 ,
4776767bd61SMark Peek.Xr closedir 3 ,
4786767bd61SMark Peek.Xr opendir 3 ,
4796767bd61SMark Peek.Xr readdir 3 ,
4806767bd61SMark Peek.Xr malloc 3 ,
4816767bd61SMark Peekand
4826767bd61SMark Peek.Xr free 3 .
483