Commit | Line | Data |
---|---|---|
ae59e04c | 1 | .\" Copyright (c) 1989, 1991 The Regents of the University of California. |
a80f0b27 KB |
2 | .\" All rights reserved. |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" Guido van Rossum. | |
91cff1e1 | 6 | .\" %sccs.include.redist.man% |
a80f0b27 | 7 | .\" |
e4dacb25 | 8 | .\" @(#)fnmatch.3 5.4 (Berkeley) %G% |
a80f0b27 | 9 | .\" |
ae59e04c CL |
10 | .Dd |
11 | .Dt FNMATCH 3 | |
12 | .Os | |
13 | .Sh NAME | |
14 | .Nm fnmatch | |
15 | .Nd match filename or pathname | |
16 | .Sh SYNOPSIS | |
e4dacb25 | 17 | .Fd #include <fnmatch.h> |
ae59e04c CL |
18 | .Ft int |
19 | .Fn fnmatch "const char *pattern" "const char *string" "int flags" | |
20 | .Sh DESCRIPTION | |
21 | The | |
22 | .Fn fnmatch | |
23 | function | |
a80f0b27 KB |
24 | matches patterns according to the rules used by the shell. |
25 | It checks the string specified by the | |
ae59e04c | 26 | .Fa string |
a80f0b27 | 27 | argument to see if it matches the pattern specified by the |
ae59e04c | 28 | .Fa pattern |
a80f0b27 | 29 | argument. |
ae59e04c | 30 | .Pp |
a80f0b27 | 31 | The |
ae59e04c | 32 | .Fa flags |
a80f0b27 | 33 | argument modifies the interpretation of |
ae59e04c | 34 | .Fa pattern |
a80f0b27 | 35 | and |
ae59e04c | 36 | .Fa string . |
a80f0b27 | 37 | The value of |
ae59e04c CL |
38 | .Fa flags |
39 | is the bitwise inclusive | |
40 | .Tn OR | |
41 | of any of the following | |
a80f0b27 | 42 | constants, which are defined in the include file |
e4dacb25 | 43 | .Pa fnmatch.h . |
ae59e04c | 44 | .Bl -tag -width FNM_PATHNAME |
e4dacb25 KB |
45 | .It Dv FNM_NOESCAPE |
46 | Normally, every occurrence of a backslash | |
47 | .Pq Ql \e | |
48 | followed by a character in | |
49 | .Fa pattern | |
50 | is replaced by that character. | |
51 | This is done to negate any special meaning for the character. | |
52 | If the | |
53 | .Dv FNM_NOESCAPE | |
54 | flag is set, a backslash character is treated as an ordinary character. | |
ae59e04c | 55 | .It Dv FNM_PATHNAME |
a80f0b27 | 56 | Slash characters in |
ae59e04c | 57 | .Fa string |
a80f0b27 | 58 | must be explicitly matched by slashes in |
ae59e04c | 59 | .Fa pattern . |
a80f0b27 | 60 | If this flag is not set, then slashes are treated as regular characters. |
e4dacb25 KB |
61 | .It Dv FNM_PERIOD |
62 | Leading periods in strings match periods in patterns. | |
63 | The definition of ``leading'' is related to the specification of | |
64 | .Dv FNM_PATHNAME. | |
65 | A period is always ``leading'' if it is the first character in | |
66 | .Ar string . | |
67 | Additionally, if | |
68 | .Dv FNM_PATHNAME | |
69 | is set, | |
70 | a period is ``leading'' if it immediately follows a slash. | |
71 | .Em "This flag is not currently implemented." | |
ae59e04c CL |
72 | .El |
73 | .Sh RETURN VALUES | |
e4dacb25 KB |
74 | The |
75 | .Fn fnmatch | |
76 | function returns zero if | |
ae59e04c | 77 | .Fa string |
a80f0b27 | 78 | matches the pattern specified by |
ae59e04c | 79 | .Fa pattern , |
e4dacb25 KB |
80 | otherwise, it returns the value |
81 | .Dv FNM_NOMATCH . | |
ae59e04c CL |
82 | .Sh SEE ALSO |
83 | .Xr sh 1 , | |
84 | .Xr glob 3 , | |
85 | .Xr wordexp 3 , | |
86 | .Xr regexp 3 | |
87 | .Sh HISTORY | |
88 | The | |
89 | .Fn fnmatch | |
90 | function is | |
91 | .Ud . | |
92 | .Sh BUGS | |
e4dacb25 KB |
93 | Quotes and slashes in range patterns are not handled correctly by |
94 | this implementation. | |
95 | .Pp | |
96 | The | |
97 | .Dv FNM_PERIOD | |
98 | flag is not implemented. | |
ae59e04c CL |
99 | .Pp |
100 | The pattern | |
101 | .Ql * | |
102 | matches the empty string, even if | |
103 | .Dv FNM_PATHNAME | |
a80f0b27 | 104 | is specified. |