1.\" $OpenBSD: fnmatch.3,v 1.9 2000/12/24 00:30:47 aaron Exp $ 2.\" 3.\" Copyright (c) 1989, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" Guido van Rossum. 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. All advertising materials mentioning features or use of this software 17.\" must display the following acknowledgement: 18.\" This product includes software developed by the University of 19.\" California, Berkeley and its contributors. 20.\" 4. Neither the name of the University nor the names of its contributors 21.\" may be used to endorse or promote products derived from this software 22.\" without specific prior written permission. 23.\" 24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34.\" SUCH DAMAGE. 35.\" 36.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95 37.\" 38.Dd April 28, 1995 39.Dt FNMATCH 3 40.Os 41.Sh NAME 42.Nm fnmatch 43.Nd match filename or pathname using shell globbing rules 44.Sh SYNOPSIS 45.Fd #include <fnmatch.h> 46.Ft int 47.Fn fnmatch "const char *pattern" "const char *string" "int flags" 48.Sh DESCRIPTION 49The 50.Fn fnmatch 51function matches patterns according to the globbing rules used by the shell. 52It checks the string specified by the 53.Fa string 54argument to see if it matches the pattern specified by the 55.Fa pattern 56argument. 57.Pp 58The 59.Fa flags 60argument modifies the interpretation of 61.Fa pattern 62and 63.Fa string . 64The value of 65.Fa flags 66is the bitwise inclusive 67.Tn OR 68of any of the following 69constants, which are defined in the include file 70.Aq Pa fnmatch.h . 71.Bl -tag -width FNM_PATHNAME 72.It Dv FNM_NOESCAPE 73Normally, every occurrence of a backslash 74.Pq Sq \e 75followed by a character in 76.Fa pattern 77is replaced by that character. 78This is done to negate any special meaning for the character. 79If the 80.Dv FNM_NOESCAPE 81flag is set, a backslash character is treated as an ordinary character. 82.It Dv FNM_PATHNAME 83Slash characters in 84.Fa string 85must be explicitly matched by slashes in 86.Fa pattern . 87If this flag is not set, then slashes are treated as regular characters. 88.It Dv FNM_PERIOD 89Leading periods in 90.Fa string 91must be explicitly matched by periods in 92.Fa pattern . 93If this flag is not set, then leading periods are treated as regular 94characters. 95The definition of 96.Dq leading 97is related to the specification of 98.Dv FNM_PATHNAME . 99A period is always leading 100if it is the first character in 101.Fa string . 102Additionally, if 103.Dv FNM_PATHNAME 104is set, 105a period is leading 106if it immediately follows a slash. 107.It Dv FNM_LEADING_DIR 108Ignore 109.Nm /* 110rest after successful 111.Fa pattern 112matching. 113.It Dv FNM_CASEFOLD 114Ignore case distinctions in both the 115.Fa pattern 116and the 117.Fa string . 118.El 119.Sh RETURN VALUES 120The 121.Fn fnmatch 122function returns zero if 123.Fa string 124matches the pattern specified by 125.Fa pattern , 126otherwise, it returns the value 127.Dv FNM_NOMATCH . 128.Sh SEE ALSO 129.Xr sh 1 , 130.Xr glob 3 , 131.Xr regex 3 132.Sh STANDARDS 133The 134.Fn fnmatch 135function conforms to 136.St -p1003.2-92 137and 138.St -xpg4.2 . 139.Pp 140Note, however, that the flags 141.Dv FNM_LEADING_DIR 142and 143.Dv FNM_CASEFOLD 144are extensions and should not be used by applications striving for 145strict standards conformance. 146.Sh HISTORY 147The 148.Fn fnmatch 149function first appeared in 150.Bx 4.4 . 151.Sh BUGS 152The pattern 153.Ql * 154matches the empty string, even if 155.Dv FNM_PATHNAME 156is specified. 157