date and time created 93/05/24 10:58:50 by bostic
[unix-history] / usr / src / lib / libc / gen / fnmatch.3
CommitLineData
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
21The
22.Fn fnmatch
23function
a80f0b27
KB
24matches patterns according to the rules used by the shell.
25It checks the string specified by the
ae59e04c 26.Fa string
a80f0b27 27argument to see if it matches the pattern specified by the
ae59e04c 28.Fa pattern
a80f0b27 29argument.
ae59e04c 30.Pp
a80f0b27 31The
ae59e04c 32.Fa flags
a80f0b27 33argument modifies the interpretation of
ae59e04c 34.Fa pattern
a80f0b27 35and
ae59e04c 36.Fa string .
a80f0b27 37The value of
ae59e04c
CL
38.Fa flags
39is the bitwise inclusive
40.Tn OR
41of any of the following
a80f0b27 42constants, 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
46Normally, every occurrence of a backslash
47.Pq Ql \e
48followed by a character in
49.Fa pattern
50is replaced by that character.
51This is done to negate any special meaning for the character.
52If the
53.Dv FNM_NOESCAPE
54flag is set, a backslash character is treated as an ordinary character.
ae59e04c 55.It Dv FNM_PATHNAME
a80f0b27 56Slash characters in
ae59e04c 57.Fa string
a80f0b27 58must be explicitly matched by slashes in
ae59e04c 59.Fa pattern .
a80f0b27 60If this flag is not set, then slashes are treated as regular characters.
e4dacb25
KB
61.It Dv FNM_PERIOD
62Leading periods in strings match periods in patterns.
63The definition of ``leading'' is related to the specification of
64.Dv FNM_PATHNAME.
65A period is always ``leading'' if it is the first character in
66.Ar string .
67Additionally, if
68.Dv FNM_PATHNAME
69is set,
70a 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
74The
75.Fn fnmatch
76function returns zero if
ae59e04c 77.Fa string
a80f0b27 78matches the pattern specified by
ae59e04c 79.Fa pattern ,
e4dacb25
KB
80otherwise, 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
88The
89.Fn fnmatch
90function is
91.Ud .
92.Sh BUGS
e4dacb25
KB
93Quotes and slashes in range patterns are not handled correctly by
94this implementation.
95.Pp
96The
97.Dv FNM_PERIOD
98flag is not implemented.
ae59e04c
CL
99.Pp
100The pattern
101.Ql *
102matches the empty string, even if
103.Dv FNM_PATHNAME
a80f0b27 104is specified.