16767bd61SMark Peek.\" $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. 166767bd61SMark Peek.\" 3. All advertising materials mentioning features or use of this software 176767bd61SMark Peek.\" must display the following acknowledgement: 186767bd61SMark Peek.\" This product includes software developed by the University of 196767bd61SMark Peek.\" California, Berkeley and its contributors. 206767bd61SMark Peek.\" 4. Neither the name of the University nor the names of its contributors 216767bd61SMark Peek.\" may be used to endorse or promote products derived from this software 226767bd61SMark Peek.\" without specific prior written permission. 23c80476e4SDavid E. O'Brien.\" 246767bd61SMark Peek.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 256767bd61SMark Peek.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 266767bd61SMark Peek.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 276767bd61SMark Peek.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 286767bd61SMark Peek.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 296767bd61SMark Peek.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 306767bd61SMark Peek.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 316767bd61SMark Peek.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 326767bd61SMark Peek.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 336767bd61SMark Peek.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 346767bd61SMark Peek.\" SUCH DAMAGE. 35c80476e4SDavid E. O'Brien.\" 366767bd61SMark Peek.\" @(#)glob.3 8.3 (Berkeley) 4/16/94 37c80476e4SDavid E. O'Brien.\" 386767bd61SMark Peek.Dd March 31, 1998 396767bd61SMark Peek.Dt GLOB 3 406767bd61SMark Peek.Os 416767bd61SMark Peek.Sh NAME 426767bd61SMark Peek.Nm glob , 436767bd61SMark Peek.Nm globfree 446767bd61SMark Peek.Nd generate pathnames matching a pattern 456767bd61SMark Peek.Sh LIBRARY 466767bd61SMark Peek.Lb libc 476767bd61SMark Peek.Sh SYNOPSIS 486767bd61SMark Peek.Fd #include <glob.h> 496767bd61SMark Peek.Ft int 506767bd61SMark Peek.Fn glob "const char *pattern" "int flags" "const int (*errfunc)(const char *, int)" "glob_t *pglob" 516767bd61SMark Peek.Ft void 526767bd61SMark Peek.Fn globfree "glob_t *pglob" 536767bd61SMark Peek.Sh DESCRIPTION 546767bd61SMark PeekThe 556767bd61SMark Peek.Fn glob 566767bd61SMark Peekfunction 57c80476e4SDavid E. O'Brienis a pathname generator that implements the rules for file name pattern 58c80476e4SDavid E. O'Brienmatching used by the shell. 596767bd61SMark Peek.Pp 60c80476e4SDavid E. O'BrienThe include file 616767bd61SMark Peek.Pa glob.h 62c80476e4SDavid E. O'Briendefines the structure type 636767bd61SMark Peek.Fa glob_t , 64c80476e4SDavid E. O'Brienwhich contains at least the following fields: 656767bd61SMark Peek.Bd -literal 66c80476e4SDavid E. O'Brientypedef struct { 67c80476e4SDavid E. O'Brien int gl_pathc; /* count of total paths so far */ 68c80476e4SDavid E. O'Brien int gl_matchc; /* count of paths matching pattern */ 69c80476e4SDavid E. O'Brien int gl_offs; /* reserved at beginning of gl_pathv */ 70c80476e4SDavid E. O'Brien int gl_flags; /* returned flags */ 71c80476e4SDavid E. O'Brien char **gl_pathv; /* list of paths matching pattern */ 72c80476e4SDavid E. O'Brien} glob_t; 736767bd61SMark Peek.Ed 746767bd61SMark Peek.Pp 75c80476e4SDavid E. O'BrienThe argument 766767bd61SMark Peek.Fa pattern 77c80476e4SDavid E. O'Brienis a pointer to a pathname pattern to be expanded. 786767bd61SMark PeekThe 796767bd61SMark Peek.Fn glob 806767bd61SMark Peekargument 81c80476e4SDavid E. O'Brienmatches all accessible pathnames against the pattern and creates 82c80476e4SDavid E. O'Briena list of the pathnames that match. 83c80476e4SDavid E. O'BrienIn order to have access to a pathname, 846767bd61SMark Peek.Fn glob 85c80476e4SDavid E. O'Brienrequires search permission on every component of a path except the last 86c80476e4SDavid E. O'Brienand read permission on each directory of any filename component of 876767bd61SMark Peek.Fa pattern 886767bd61SMark Peekthat contains any of the special characters 896767bd61SMark Peek.Ql * , 906767bd61SMark Peek.Ql ? 916767bd61SMark Peekor 926767bd61SMark Peek.Ql [ . 936767bd61SMark Peek.Pp 946767bd61SMark PeekThe 956767bd61SMark Peek.Fn glob 966767bd61SMark Peekargument 97c80476e4SDavid E. O'Brienstores the number of matched pathnames into the 986767bd61SMark Peek.Fa gl_pathc 99c80476e4SDavid E. O'Brienfield, and a pointer to a list of pointers to pathnames into the 1006767bd61SMark Peek.Fa gl_pathv 101c80476e4SDavid E. O'Brienfield. 1026767bd61SMark PeekThe first pointer after the last pathname is 1036767bd61SMark Peek.Dv NULL . 104c80476e4SDavid E. O'BrienIf the pattern does not match any pathnames, the returned number of 105c80476e4SDavid E. O'Brienmatched paths is set to zero. 1066767bd61SMark Peek.Pp 107c80476e4SDavid E. O'BrienIt is the caller's responsibility to create the structure pointed to by 1086767bd61SMark Peek.Fa pglob . 109c80476e4SDavid E. O'BrienThe 1106767bd61SMark Peek.Fn glob 111c80476e4SDavid E. O'Brienfunction allocates other space as needed, including the memory pointed 112c80476e4SDavid E. O'Briento by 1136767bd61SMark Peek.Fa gl_pathv . 1146767bd61SMark Peek.Pp 115c80476e4SDavid E. O'BrienThe argument 1166767bd61SMark Peek.Fa flags 117c80476e4SDavid E. O'Brienis used to modify the behavior of 1186767bd61SMark Peek.Fn glob . 119c80476e4SDavid E. O'BrienThe value of 1206767bd61SMark Peek.Fa flags 1216767bd61SMark Peekis the bitwise inclusive 1226767bd61SMark Peek.Tn OR 1236767bd61SMark Peekof any of the following 124c80476e4SDavid E. O'Brienvalues defined in 1256767bd61SMark Peek.Pa glob.h : 1266767bd61SMark Peek.Bl -tag -width GLOB_ALTDIRFUNC 1276767bd61SMark Peek.It Dv GLOB_APPEND 128c80476e4SDavid E. O'BrienAppend pathnames generated to the ones from a previous call (or calls) 129c80476e4SDavid E. O'Briento 1306767bd61SMark Peek.Fn glob . 131c80476e4SDavid E. O'BrienThe value of 1326767bd61SMark Peek.Fa gl_pathc 133c80476e4SDavid E. O'Brienwill be the total matches found by this call and the previous call(s). 134c80476e4SDavid E. O'BrienThe pathnames are appended to, not merged with the pathnames returned by 135c80476e4SDavid E. O'Brienthe previous call(s). 136c80476e4SDavid E. O'BrienBetween calls, the caller must not change the setting of the 1376767bd61SMark Peek.Dv GLOB_DOOFFS 1386767bd61SMark Peekflag, nor change the value of 1396767bd61SMark Peek.Fa gl_offs 140c80476e4SDavid E. O'Brienwhen 1416767bd61SMark Peek.Dv GLOB_DOOFFS 1426767bd61SMark Peekis set, nor (obviously) call 1436767bd61SMark Peek.Fn globfree 144c80476e4SDavid E. O'Brienfor 1456767bd61SMark Peek.Fa pglob . 1466767bd61SMark Peek.It Dv GLOB_DOOFFS 147c80476e4SDavid E. O'BrienMake use of the 1486767bd61SMark Peek.Fa gl_offs 149c80476e4SDavid E. O'Brienfield. 150c80476e4SDavid E. O'BrienIf this flag is set, 1516767bd61SMark Peek.Fa gl_offs 1526767bd61SMark Peekis used to specify how many 1536767bd61SMark Peek.Dv NULL 1546767bd61SMark Peekpointers to prepend to the beginning 155c80476e4SDavid E. O'Brienof the 1566767bd61SMark Peek.Fa gl_pathv 157c80476e4SDavid E. O'Brienfield. 158c80476e4SDavid E. O'BrienIn other words, 1596767bd61SMark Peek.Fa gl_pathv 160c80476e4SDavid E. O'Brienwill point to 1616767bd61SMark Peek.Fa gl_offs 1626767bd61SMark Peek.Dv NULL 1636767bd61SMark Peekpointers, 164c80476e4SDavid E. O'Brienfollowed by 1656767bd61SMark Peek.Fa gl_pathc 1666767bd61SMark Peekpathname pointers, followed by a 1676767bd61SMark Peek.Dv NULL 1686767bd61SMark Peekpointer. 1696767bd61SMark Peek.It Dv GLOB_ERR 170c80476e4SDavid E. O'BrienCauses 1716767bd61SMark Peek.Fn glob 172c80476e4SDavid E. O'Briento return when it encounters a directory that it cannot open or read. 173c80476e4SDavid E. O'BrienOrdinarily, 1746767bd61SMark Peek.Fn glob 175c80476e4SDavid E. O'Briencontinues to find matches. 1766767bd61SMark Peek.It Dv GLOB_MARK 177c80476e4SDavid E. O'BrienEach pathname that is a directory that matches 1786767bd61SMark Peek.Fa pattern 179c80476e4SDavid E. O'Brienhas a slash 180c80476e4SDavid E. O'Brienappended. 1816767bd61SMark Peek.It Dv GLOB_NOCHECK 182c80476e4SDavid E. O'BrienIf 1836767bd61SMark Peek.Fa pattern 184c80476e4SDavid E. O'Briendoes not match any pathname, then 1856767bd61SMark Peek.Fn glob 186c80476e4SDavid E. O'Brienreturns a list 187c80476e4SDavid E. O'Brienconsisting of only 1886767bd61SMark Peek.Fa pattern , 189c80476e4SDavid E. O'Brienwith the number of total pathnames is set to 1, and the number of matched 190c80476e4SDavid E. O'Brienpathnames set to 0. 1916767bd61SMark Peek.It Dv GLOB_NOSORT 1926767bd61SMark PeekBy default, the pathnames are sorted in ascending 1936767bd61SMark Peek.Tn ASCII 1946767bd61SMark Peekorder; 1956767bd61SMark Peekthis flag prevents that sorting (speeding up 1966767bd61SMark Peek.Fn glob ) . 1976767bd61SMark Peek.El 1986767bd61SMark Peek.Pp 1996767bd61SMark PeekThe following values may also be included in 2006767bd61SMark Peek.Fa flags , 2016767bd61SMark Peekhowever, they are non-standard extensions to 2026767bd61SMark Peek.St -p1003.2 . 2036767bd61SMark Peek.Bl -tag -width GLOB_ALTDIRFUNC 2046767bd61SMark Peek.It Dv GLOB_ALTDIRFUNC 2056767bd61SMark PeekThe following additional fields in the pglob structure have been 2066767bd61SMark Peekinitialized with alternate functions for glob to use to open, read, 2076767bd61SMark Peekand close directories and to get stat information on names found 2086767bd61SMark Peekin those directories. 2096767bd61SMark Peek.Bd -literal 2106767bd61SMark Peek void *(*gl_opendir)(const char * name); 2116767bd61SMark Peek struct dirent *(*gl_readdir)(void *); 2126767bd61SMark Peek void (*gl_closedir)(void *); 2136767bd61SMark Peek int (*gl_lstat)(const char *name, struct stat *st); 2146767bd61SMark Peek int (*gl_stat)(const char *name, struct stat *st); 2156767bd61SMark Peek.Ed 2166767bd61SMark Peek.Pp 2176767bd61SMark PeekThis extension is provided to allow programs such as 2186767bd61SMark Peek.Xr restore 8 2196767bd61SMark Peekto provide globbing from directories stored on tape. 2206767bd61SMark Peek.It Dv GLOB_BRACE 2216767bd61SMark PeekPre-process the pattern string to expand 2226767bd61SMark Peek.Ql {pat,pat,...} 2236767bd61SMark Peekstrings like 2246767bd61SMark Peek.Xr csh 1 . 2256767bd61SMark PeekThe pattern 2266767bd61SMark Peek.Ql {} 2276767bd61SMark Peekis left unexpanded for historical reasons 2286767bd61SMark Peek.Po 2296767bd61SMark Peek.Xr csh 1 2306767bd61SMark Peekdoes the same thing to ease typing of 2316767bd61SMark Peek.Xr find 1 2326767bd61SMark Peekpatterns 2336767bd61SMark Peek.Pc . 2346767bd61SMark Peek.It Dv GLOB_MAGCHAR 2356767bd61SMark PeekSet by the 2366767bd61SMark Peek.Fn glob 2376767bd61SMark Peekfunction if the pattern included globbing characters. 2386767bd61SMark PeekSee the description of the usage of the 2396767bd61SMark Peek.Fa gl_matchc 2406767bd61SMark Peekstructure member for more details. 2416767bd61SMark Peek.It Dv GLOB_NOMAGIC 2426767bd61SMark PeekIs the same as 2436767bd61SMark Peek.Dv GLOB_NOCHECK 2446767bd61SMark Peekbut it only appends the 2456767bd61SMark Peek.Fa pattern 246c80476e4SDavid E. O'Brienif it does not contain any of the special characters ``*'', ``?'' or ``[''. 2476767bd61SMark Peek.Dv GLOB_NOMAGIC 2486767bd61SMark Peekis provided to simplify implementing the historic 2496767bd61SMark Peek.Xr csh 1 2506767bd61SMark Peekglobbing behavior and should probably not be used anywhere else. 2516767bd61SMark Peek.It Dv GLOB_NOESCAPE 2526767bd61SMark PeekDisable the use of the backslash 2536767bd61SMark Peek.Pq Ql \e 2546767bd61SMark Peekcharacter for quoting. 2556767bd61SMark Peek.It Dv GLOB_TILDE 2566767bd61SMark PeekExpand patterns that start with 2576767bd61SMark Peek.Ql ~ 2586767bd61SMark Peekto user name home directories. 2596767bd61SMark Peek.It Dv GLOB_LIMIT 2606767bd61SMark PeekLimit the amount of memory used by matches to 2616767bd61SMark Peek.Li ARG_MAX 2626767bd61SMark PeekThis option should be set for programs that can be coerced to a denial of 2636767bd61SMark Peekservice attack via patterns that expand to a very large number of matches, 2646767bd61SMark Peeksuch as a long string of 2656767bd61SMark Peek.Li */../*/.. 2666767bd61SMark Peek.El 2676767bd61SMark Peek.Pp 268c80476e4SDavid E. O'BrienIf, during the search, a directory is encountered that cannot be opened 269c80476e4SDavid E. O'Brienor read and 2706767bd61SMark Peek.Fa errfunc 2716767bd61SMark Peekis 2726767bd61SMark Peek.Pf non- Dv NULL , 2736767bd61SMark Peek.Fn glob 2746767bd61SMark Peekcalls 2756767bd61SMark Peek.Fa (*errfunc)(path, errno) . 2766767bd61SMark PeekThis may be unintuitive: a pattern like 2776767bd61SMark Peek.Ql */Makefile 2786767bd61SMark Peekwill try to 2796767bd61SMark Peek.Xr stat 2 2806767bd61SMark Peek.Ql foo/Makefile 2816767bd61SMark Peekeven if 2826767bd61SMark Peek.Ql foo 2836767bd61SMark Peekis not a directory, resulting in a 284c80476e4SDavid E. O'Briencall to 2856767bd61SMark Peek.Fa errfunc . 2866767bd61SMark PeekThe error routine can suppress this action by testing for 2876767bd61SMark Peek.Dv ENOENT 288c80476e4SDavid E. O'Brienand 2896767bd61SMark Peek.Dv ENOTDIR ; 2906767bd61SMark Peekhowever, the 2916767bd61SMark Peek.Dv GLOB_ERR 2926767bd61SMark Peekflag will still cause an immediate 2936767bd61SMark Peekreturn when this happens. 2946767bd61SMark Peek.Pp 2956767bd61SMark PeekIf 2966767bd61SMark Peek.Fa errfunc 2976767bd61SMark Peekreturns non-zero, 2986767bd61SMark Peek.Fn glob 2996767bd61SMark Peekstops the scan and returns 3006767bd61SMark Peek.Dv GLOB_ABORTED 3016767bd61SMark Peekafter setting 3026767bd61SMark Peek.Fa gl_pathc 3036767bd61SMark Peekand 3046767bd61SMark Peek.Fa gl_pathv 305c80476e4SDavid E. O'Briento reflect any paths already matched. 306c80476e4SDavid E. O'BrienThis also happens if an error is encountered and 3076767bd61SMark Peek.Dv GLOB_ERR 308c80476e4SDavid E. O'Brienis set in 3096767bd61SMark Peek.Fa flags , 310c80476e4SDavid E. O'Brienregardless of the return value of 3116767bd61SMark Peek.Fa errfunc , 312c80476e4SDavid E. O'Brienif called. 313c80476e4SDavid E. O'BrienIf 3146767bd61SMark Peek.Dv GLOB_ERR 315c80476e4SDavid E. O'Brienis not set and either 3166767bd61SMark Peek.Fa errfunc 3176767bd61SMark Peekis 3186767bd61SMark Peek.Dv NULL 3196767bd61SMark Peekor 3206767bd61SMark Peek.Fa errfunc 321c80476e4SDavid E. O'Brienreturns zero, the error is ignored. 3226767bd61SMark Peek.Pp 323c80476e4SDavid E. O'BrienThe 3246767bd61SMark Peek.Fn globfree 325c80476e4SDavid E. O'Brienfunction frees any space associated with 3266767bd61SMark Peek.Fa pglob 327c80476e4SDavid E. O'Brienfrom a previous call(s) to 3286767bd61SMark Peek.Fn glob . 3296767bd61SMark Peek.Pp 3306767bd61SMark PeekThe historical 3316767bd61SMark Peek.Dv GLOB_QUOTE 3326767bd61SMark Peekflag is no longer supported. 3336767bd61SMark PeekPer 3346767bd61SMark Peek.St -p1003.2-92 , 3356767bd61SMark Peekbackslash escaping of special characters is the default behaviour; 3366767bd61SMark Peekit may be disabled by specifying the 3376767bd61SMark Peek.Dv GLOB_NOESCAPE 3386767bd61SMark Peekflag. 3396767bd61SMark Peek.Sh RETURN VALUES 340c80476e4SDavid E. O'BrienOn successful completion, 3416767bd61SMark Peek.Fn glob 342c80476e4SDavid E. O'Brienreturns zero. 343c80476e4SDavid E. O'BrienIn addition the fields of 3446767bd61SMark Peek.Fa pglob 345c80476e4SDavid E. O'Briencontain the values described below: 3466767bd61SMark Peek.Bl -tag -width GLOB_NOCHECK 3476767bd61SMark Peek.It Fa gl_pathc 348c80476e4SDavid E. O'Briencontains the total number of matched pathnames so far. 349c80476e4SDavid E. O'BrienThis includes other matches from previous invocations of 3506767bd61SMark Peek.Fn glob 351c80476e4SDavid E. O'Brienif 3526767bd61SMark Peek.Dv GLOB_APPEND 353c80476e4SDavid E. O'Brienwas specified. 3546767bd61SMark Peek.It Fa gl_matchc 355c80476e4SDavid E. O'Briencontains the number of matched pathnames in the current invocation of 3566767bd61SMark Peek.Fn glob . 3576767bd61SMark Peek.It Fa gl_flags 358c80476e4SDavid E. O'Briencontains a copy of the 3596767bd61SMark Peek.Fa flags 3606767bd61SMark Peekparameter with the bit 3616767bd61SMark Peek.Dv GLOB_MAGCHAR 3626767bd61SMark Peekset if 3636767bd61SMark Peek.Fa pattern 364c80476e4SDavid E. O'Briencontained any of the special characters ``*'', ``?'' or ``['', cleared 365c80476e4SDavid E. O'Brienif not. 3666767bd61SMark Peek.It Fa gl_pathv 3676767bd61SMark Peekcontains a pointer to a 3686767bd61SMark Peek.Dv NULL Ns -terminated 3696767bd61SMark Peeklist of matched pathnames. 370c80476e4SDavid E. O'BrienHowever, if 3716767bd61SMark Peek.Fa gl_pathc 372c80476e4SDavid E. O'Brienis zero, the contents of 3736767bd61SMark Peek.Fa gl_pathv 374c80476e4SDavid E. O'Brienare undefined. 3756767bd61SMark Peek.El 3766767bd61SMark Peek.Pp 377c80476e4SDavid E. O'BrienIf 3786767bd61SMark Peek.Fn glob 3796767bd61SMark Peekterminates due to an error, it sets 3806767bd61SMark Peek.Va errno 3816767bd61SMark Peekand returns one of the following non-zero constants, which are defined 3826767bd61SMark Peekin the include file 3836767bd61SMark Peek.Aq Pa glob.h : 3846767bd61SMark Peek.Bl -tag -width GLOB_ABORTEDXXX 3856767bd61SMark Peek.It Dv GLOB_ABORTED 386c80476e4SDavid E. O'BrienThe scan was stopped because an error was encountered and either 3876767bd61SMark Peek.Dv GLOB_ERR 3886767bd61SMark Peekwas set or 3896767bd61SMark Peek.Fa (*errfunc)() 3906767bd61SMark Peekreturned non-zero. 3916767bd61SMark Peek.It Dv GLOB_NOMATCH 3926767bd61SMark PeekThe pattern does not match any existing pathname, and 3936767bd61SMark Peek.Dv GLOB_NOCHECK 3946767bd61SMark Peekwas not set int 3956767bd61SMark Peek.Dv flags . 3966767bd61SMark Peek.It Dv GLOB_NOSPACE 3976767bd61SMark PeekAn attempt to allocate memory failed, or if 3986767bd61SMark Peek.Va errno 3996767bd61SMark Peekwas 0 4006767bd61SMark Peek.Li GLOB_LIMIT 4016767bd61SMark Peekwas specified in the flags and 4026767bd61SMark Peek.Li ARG_MAX 4036767bd61SMark Peekpatterns were matched. 4046767bd61SMark Peek.El 4056767bd61SMark Peek.Pp 4066767bd61SMark PeekThe historical 4076767bd61SMark Peek.Dv GLOB_ABEND 4086767bd61SMark Peekreturn constant is no longer supported. Portable applications should use the 4096767bd61SMark Peek.Dv GLOB_ABORTED 4106767bd61SMark Peekconstant instead. 4116767bd61SMark Peek.Pp 412c80476e4SDavid E. O'BrienThe arguments 4136767bd61SMark Peek.Fa pglob\->gl_pathc 414c80476e4SDavid E. O'Brienand 4156767bd61SMark Peek.Fa pglob\->gl_pathv 416c80476e4SDavid E. O'Brienare still set as specified above. 4176767bd61SMark Peek.Sh ENVIRONMENT 4186767bd61SMark Peek.Bl -tag -width HOME -compact 4196767bd61SMark Peek.It Ev HOME 4206767bd61SMark PeekIf defined, used as the home directory of the current user in 4216767bd61SMark Peektilde expansions. 4226767bd61SMark Peek.El 4236767bd61SMark Peek.Sh EXAMPLE 4246767bd61SMark PeekA rough equivalent of 4256767bd61SMark Peek.Ql "ls -l *.c *.h" 4266767bd61SMark Peekcan be obtained with the 427c80476e4SDavid E. O'Brienfollowing code: 4286767bd61SMark Peek.Bd -literal -offset indent 429c80476e4SDavid E. O'Brienglob_t g; 430c80476e4SDavid E. O'Brien 431c80476e4SDavid E. O'Brieng.gl_offs = 2; 432c80476e4SDavid E. O'Brienglob("*.c", GLOB_DOOFFS, NULL, &g); 433c80476e4SDavid E. O'Brienglob("*.h", GLOB_DOOFFS | GLOB_APPEND, NULL, &g); 434c80476e4SDavid E. O'Brieng.gl_pathv[0] = "ls"; 435c80476e4SDavid E. O'Brieng.gl_pathv[1] = "-l"; 436c80476e4SDavid E. O'Brienexecvp("ls", g.gl_pathv); 4376767bd61SMark Peek.Ed 4386767bd61SMark Peek.Sh SEE ALSO 4396767bd61SMark Peek.Xr sh 1 , 4406767bd61SMark Peek.Xr fnmatch 3 , 4416767bd61SMark Peek.Xr regexp 3 4426767bd61SMark Peek.Sh STANDARDS 4436767bd61SMark PeekThe 4446767bd61SMark Peek.Fn glob 4456767bd61SMark Peekfunction is expected to be 4466767bd61SMark Peek.St -p1003.2 4476767bd61SMark Peekcompatible with the exception 4486767bd61SMark Peekthat the flags 4496767bd61SMark Peek.Dv GLOB_ALTDIRFUNC, 4506767bd61SMark Peek.Dv GLOB_BRACE 4516767bd61SMark Peek.Dv GLOB_MAGCHAR, 4526767bd61SMark Peek.Dv GLOB_NOMAGIC, 4536767bd61SMark Peek.Dv GLOB_TILDE, 454c80476e4SDavid E. O'Brienand 4556767bd61SMark Peek.Dv GLOB_LIMIT 4566767bd61SMark Peekand the fields 4576767bd61SMark Peek.Fa gl_matchc 4586767bd61SMark Peekand 4596767bd61SMark Peek.Fa gl_flags 4606767bd61SMark Peekshould not be used by applications striving for strict 4616767bd61SMark Peek.Tn POSIX 4626767bd61SMark Peekconformance. 4636767bd61SMark Peek.Sh HISTORY 4646767bd61SMark PeekThe 4656767bd61SMark Peek.Fn glob 4666767bd61SMark Peekand 4676767bd61SMark Peek.Fn globfree 4686767bd61SMark Peekfunctions first appeared in 4696767bd61SMark Peek.Bx 4.4 . 4706767bd61SMark Peek.Sh BUGS 4716767bd61SMark PeekPatterns longer than 4726767bd61SMark Peek.Dv MAXPATHLEN 4736767bd61SMark Peekmay cause unchecked errors. 4746767bd61SMark Peek.Pp 4756767bd61SMark PeekThe 4766767bd61SMark Peek.Fn glob 4776767bd61SMark Peekfunction may fail and set 4786767bd61SMark Peek.Va errno 4796767bd61SMark Peekfor any of the errors specified for the library routines 4806767bd61SMark Peek.Xr stat 2 , 4816767bd61SMark Peek.Xr closedir 3 , 4826767bd61SMark Peek.Xr opendir 3 , 4836767bd61SMark Peek.Xr readdir 3 , 4846767bd61SMark Peek.Xr malloc 3 , 4856767bd61SMark Peekand 4866767bd61SMark Peek.Xr free 3 . 487