Commit | Line | Data |
---|---|---|
34e8f829 A |
1 | --- glob.3.orig 2009-05-12 11:21:55.000000000 -0700 |
2 | +++ glob.3 2009-05-20 15:39:07.000000000 -0700 | |
3 | @@ -34,21 +34,38 @@ | |
4 | .\" @(#)glob.3 8.3 (Berkeley) 4/16/94 | |
5 | .\" $FreeBSD: src/lib/libc/gen/glob.3,v 1.30 2004/09/01 23:28:27 tjr Exp $ | |
6 | .\" | |
7 | -.Dd September 1, 2004 | |
8 | +.Dd May 20, 2008 | |
9 | .Dt GLOB 3 | |
10 | .Os | |
11 | .Sh NAME | |
12 | .Nm glob , | |
13 | +#ifdef UNIFDEF_BLOCKS | |
14 | +.Nm glob_b , | |
15 | +#endif | |
16 | .Nm globfree | |
17 | .Nd generate pathnames matching a pattern | |
18 | -.Sh LIBRARY | |
19 | -.Lb libc | |
224c7076 A |
20 | .Sh SYNOPSIS |
21 | .In glob.h | |
22 | .Ft int | |
23 | -.Fn glob "const char *pattern" "int flags" "int (*errfunc)(const char *, int)" "glob_t *pglob" | |
24 | +.Fo glob | |
25 | +.Fa "const char *restrict pattern" | |
26 | +.Fa "int flags" | |
34e8f829 | 27 | +.Fa "int (*errfunc)(const char *epath, int errno)" |
224c7076 A |
28 | +.Fa "glob_t *restrict pglob" |
29 | +.Fc | |
34e8f829 A |
30 | +#ifdef UNIFDEF_BLOCKS |
31 | +.Ft int | |
32 | +.Fo glob_b | |
33 | +.Fa "const char *restrict pattern" | |
34 | +.Fa "int flags" | |
35 | +.Fa "int (^errblk)(const char *epath, int errno)" | |
36 | +.Fa "glob_t *restrict pglob" | |
37 | +.Fc | |
38 | +#endif | |
224c7076 A |
39 | .Ft void |
40 | -.Fn globfree "glob_t *pglob" | |
41 | +.Fo globfree | |
42 | +.Fa "glob_t *pglob" | |
43 | +.Fc | |
44 | .Sh DESCRIPTION | |
45 | The | |
46 | .Fn glob | |
34e8f829 A |
47 | @@ -326,18 +343,39 @@ |
48 | or | |
49 | .Fa errfunc | |
50 | returns zero, the error is ignored. | |
51 | +#ifdef UNIFDEF_BLOCKS | |
52 | +.Pp | |
53 | +The | |
54 | +.Fn glob_b | |
55 | +function is like | |
56 | +.Fn glob | |
57 | +except that the error callback is a block pointer instead of a function | |
58 | +pointer. | |
59 | +#endif | |
60 | .Pp | |
61 | The | |
62 | .Fn globfree | |
63 | function frees any space associated with | |
64 | .Fa pglob | |
65 | from a previous call(s) to | |
66 | +#ifdef UNIFDEF_BLOCKS | |
67 | +.Fn glob | |
68 | +or | |
69 | +.Fn glob_b . | |
70 | +#else | |
71 | .Fn glob . | |
72 | +#endif | |
73 | .Sh RETURN VALUES | |
224c7076 A |
74 | On successful completion, |
75 | .Fn glob | |
34e8f829 A |
76 | +#ifdef UNIFDEF_BLOCKS |
77 | +and | |
78 | +.Fn glob_b | |
79 | +return zero. | |
80 | +#else | |
224c7076 A |
81 | returns zero. |
82 | -In addition the fields of | |
34e8f829 | 83 | +#endif |
224c7076 A |
84 | +In addition, the fields of |
85 | .Fa pglob | |
86 | contain the values described below: | |
87 | .Bl -tag -width GLOB_NOCHECK | |
34e8f829 A |
88 | @@ -345,12 +383,22 @@ |
89 | contains the total number of matched pathnames so far. | |
90 | This includes other matches from previous invocations of | |
91 | .Fn glob | |
92 | +#ifdef UNIFDEF_BLOCKS | |
93 | +or | |
94 | +.Fn glob_b | |
95 | +#endif | |
96 | if | |
97 | .Dv GLOB_APPEND | |
98 | was specified. | |
99 | .It Fa gl_matchc | |
100 | contains the number of matched pathnames in the current invocation of | |
101 | +#ifdef UNIFDEF_BLOCKS | |
102 | +.Fn glob | |
103 | +or | |
104 | +.Fn glob_b . | |
105 | +#else | |
106 | .Fn glob . | |
107 | +#endif | |
108 | .It Fa gl_flags | |
109 | contains a copy of the | |
110 | .Fa flags | |
111 | @@ -373,6 +421,10 @@ | |
112 | .Pp | |
113 | If | |
114 | .Fn glob | |
115 | +#ifdef UNIFDEF_BLOCKS | |
116 | +or | |
117 | +.Fn glob_b | |
118 | +#endif | |
119 | terminates due to an error, it sets errno and returns one of the | |
120 | following non-zero constants, which are defined in the include | |
121 | file | |
122 | @@ -418,6 +470,18 @@ | |
224c7076 A |
123 | g.gl_pathv[1] = "-l"; |
124 | execvp("ls", g.gl_pathv); | |
125 | .Ed | |
126 | +.Sh CAVEATS | |
127 | +The | |
128 | +.Fn glob | |
34e8f829 A |
129 | +#ifdef UNIFDEF_BLOCKS |
130 | +and | |
131 | +.Fn glob_b | |
132 | +functions | |
133 | +#else | |
134 | +function | |
135 | +#endif | |
136 | +will not match filenames that begin with a period | |
224c7076 A |
137 | +unless this is specifically requested (e.g., by ".*"). |
138 | .Sh SEE ALSO | |
139 | .Xr sh 1 , | |
140 | .Xr fnmatch 3 , | |
34e8f829 A |
141 | @@ -456,6 +520,11 @@ |
142 | .Fn globfree | |
143 | functions first appeared in | |
144 | .Bx 4.4 . | |
145 | +#ifdef UNIFDEF_BLOCKS | |
146 | +The | |
147 | +.Fn glob_b | |
148 | +function first appeared in Mac OS X 10.6. | |
149 | +#endif | |
150 | .Sh BUGS | |
151 | Patterns longer than | |
152 | .Dv MAXPATHLEN | |
153 | @@ -463,7 +532,13 @@ | |
154 | .Pp | |
155 | The | |
156 | .Fn glob | |
157 | -argument | |
158 | +#ifdef UNIFDEF_BLOCKS | |
159 | +and | |
160 | +.Fn glob_b | |
161 | +functions | |
162 | +#else | |
163 | +function | |
164 | +#endif | |
165 | may fail and set errno for any of the errors specified for the | |
166 | library routines | |
167 | .Xr stat 2 , |