.\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Guido van Rossum. .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95 .\" .\" $FreeBSD$ .Dd April 28, 1995 .Dt FNMATCH 3 .Os .Sh 名称 .Nm fnmatch .Nd ファイル名かパス名を照合する .Sh 書式 .Fd #include .Ft int .Fn fnmatch "const char *pattern" "const char *string" "int flags" .Sh 解説 .Fn fnmatch 関数は、シェルが使用する規則に従ってパターンを照合します。 .Fa string 引数が指定する文字列をチェックし、 .Fa pattern 引数が指定するパターンと一致するかどうか確認します。 .Pp .Fa flags 引数は、 .Fa pattern と .Fa string の解釈を修正します。 .Fa flags の値は、以下の定数のビット単位の論理和です。この定数は、 インクルードファイル .Pa fnmatch.h で定義されています。 .Bl -tag -width FNM_PATHNAME .It Dv FNM_NOESCAPE 通常、 .Fa pattern の中でバックスラッシュ .Pq Ql \e の後ろに 1 文字が続くものが現れるごとに、それはその文字で 置き換えられます。この置き換えは、その文字の特殊な意味を 無効にするために実行されます。 .Dv FNM_NOESCAPE フラグを設定すると、バックスラッシュ文字は通常文字として扱われます。 .It Dv FNM_PATHNAME .Fa string のスラッシュ文字は、 .Fa pattern 中のスラッシュと 明確に一致する必要があります。このフラグを設定しないと、スラッシュは 通常文字として扱われます。 .It Dv FNM_PERIOD .Fa string の最初のピリオドは、 .Fa pattern 中の最初のピリオドと 明確に一致する必要があります。このフラグを設定しないと、最初のピリオドは 通常文字として扱われます。「最初の」という言葉の定義は、 .Dv FNM_PATHNAME の指定によって変化します。 .Ar string の第 1 キャラクタであるピリオドは、常に「最初の」ピリオドです。 .Dv FNM_PATHNAME を設定した場合、スラッシュの直後のピリオドも「最初の」ピリオドです。 .It Dv FNM_LEADING_DIR .Fa pattern が問題なく一致した後、残りの .Nm /* を無視します。 .It Dv FNM_CASEFOLD .Fa pattern と .Fa string の両方で大文字と小文字の区別を無視します。 .El .Sh 戻り値 .Fn fnmatch 関数は、 .Fa pattern が指定するパターンに .Fa string が一致するとゼロを戻します。一致しない場合は値 .Dv FNM_NOMATCH を戻します。 .Sh 関連項目 .Xr sh 1 , .Xr glob 3 , .Xr regex 3 .Sh 規格 .Fn fnmatch 関数は、 .St -p1003.2 に準拠しています。 .Sh 歴史 .Fn fnmatch 関数は、 .Bx 4.4 に追加されました。 .Sh バグ .Dv FNM_PATHNAME を指定しても、パターン .Ql * は空ストリングと一致します。 .\"X kuma 1999-11-5