1.\" Copyright (c) 1989, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Guido van Rossum. 6.\" %sccs.include.redist.man% 7.\" 8.\" @(#)fnmatch.3 5.3 (Berkeley) 04/19/91 9.\" 10.Dd 11.Dt FNMATCH 3 12.Os 13.Sh NAME 14.Nm fnmatch 15.Nd match filename or pathname 16.Sh SYNOPSIS 17.Fd #include <unistd.h> 18.Ft int 19.Fn fnmatch "const char *pattern" "const char *string" "int flags" 20.Sh DESCRIPTION 21The 22.Fn fnmatch 23function 24matches patterns according to the rules used by the shell. 25It checks the string specified by the 26.Fa string 27argument to see if it matches the pattern specified by the 28.Fa pattern 29argument. 30.Pp 31The 32.Fa flags 33argument modifies the interpretation of 34.Fa pattern 35and 36.Fa string . 37The value of 38.Fa flags 39is the bitwise inclusive 40.Tn OR 41of any of the following 42constants, which are defined in the include file 43.Pa unistd.h . 44.Bl -tag -width FNM_PATHNAME 45.It Dv FNM_PATHNAME 46Slash characters in 47.Fa string 48must be explicitly matched by slashes in 49.Fa pattern . 50If this flag is not set, then slashes are treated as regular characters. 51.It Dv FNM_QUOTE 52Every occurrence of a backslash 53.Pq Ql \e 54followed by a character in 55.Fa pattern 56is replaced by that character. 57This is done to negate any special meaning for the character. 58.El 59.Sh RETURN VALUES 60If 61.Fa string 62matches the pattern specified by 63.Fa pattern , 64then 65.Fn fnmatch 66returns zero. 67Otherwise, 68.Fn fnmatch 69returns nonzero. 70.Sh SEE ALSO 71.Xr sh 1 , 72.Xr glob 3 , 73.Xr wordexp 3 , 74.Xr regexp 3 75.Sh HISTORY 76The 77.Fn fnmatch 78function is 79.Ud . 80.Sh BUGS 81Quotes and slashes in range patterns are not handled correctly. 82.Pp 83The pattern 84.Ql * 85matches the empty string, even if 86.Dv FNM_PATHNAME 87is specified. 88