FNMATCH
Section: Linux Programmer's Manual (3)
Updated: 2019-03-06
Index
JM Home Page
roff page
 
名前
fnmatch - ファイル名またはパス名へのマッチを行う
 
書式
#include <fnmatch.h>
int fnmatch(const char *pattern, const char *string, int flags);
 
説明
fnmatch()  関数は strings 引数が pattern 引数にマッチするかをチェックする。 pattern
にはシェルのワイルドカードパターンを与える (glob(7) 参照)。
flags 引数により動作を変更できる。 flags は以下のフラグのビット毎の OR で指定する。
- FNM_NOESCAPE
 - 
このフラグがセットされていると、バックスラッシュ (\) をエスケープ文字 ではなく通常の文字として扱う。
 - FNM_PATHNAME
 - 
このフラグがセットされていると、 string 中のスラッシュ (/) を pattern にあるスラッシュそのものにだけマッチさせ、
アスタリスク (*) や疑問符 (?) のメタキャラクターや、 スラッシュを含むブラケット表現 ([]) にはマッチさせない。
 - FNM_PERIOD
 - 
このフラグがセットされていると、 string の先頭ピリオド (leading period) は pattern
中のピリオドそのものにしかマッチしない。先頭ピリオドとは、 string の最初の文字位置にあるピリオドのことである。ただし
FNM_PATHNAME フラグが同時にセットされている場合には、スラッシュの直後に続くピリオド も先頭ピリオドとみなされる。
 - FNM_FILE_NAME
 - 
これは FNM_PATHNAME に対する GNU での同義語である.
 - FNM_LEADING_DIR
 - 
このフラグは GNU での拡張である。これがセットされている場合には、 パターンが string の最初の部分 (にスラッシュを付けたもの)
にマッチすれば、 マッチしたものとみなされる。 このフラグは主として glibc で内部的に使用するもので、そのためにのみ実装されている。
 - FNM_CASEFOLD
 - 
このフラグは GNU での拡張である。これがセットされている場合には、 パターンのマッチに大文字小文字が区別されない。
 - FNM_EXTMATCH
 - 
If this flag (a GNU extension) is set, extended patterns are supported, as
introduced by 'ksh' and now supported by other shells.  The extended
format is as follows, with pattern-list being a '|' separated list of
patterns.
 - '?(pattern-list)'
 - 
The pattern matches if zero or one occurrences of any of the patterns in the
pattern-list match the input string.
 - '*(pattern-list)'
 - 
The pattern matches if zero or more occurrences of any of the patterns in
the pattern-list match the input string.
 - '+(pattern-list)'
 - 
The pattern matches if one or more occurrences of any of the patterns in the
pattern-list match the input string.
 - '@(pattern-list)'
 - 
The pattern matches if exactly one occurrence of any of the patterns in the
pattern-list match the input string.
 - '!(pattern-list)'
 - 
The pattern matches if the input string cannot be matched with any of the
patterns in the pattern-list.
 
 
返り値
string が pattern にマッチすれば 0 を返す。マッチしなかった場合には FNM_NOMATCH
を返す。エラーの場合にはそれ以外の非ゼロ値を返す。
 
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
  | 
| 
fnmatch()
 | Thread safety | MT-Safe env locale
  | 
 
準拠
POSIX.1-2001, POSIX.1-2008, POSIX.2.  FNM_FILE_NAME, FNM_LEADING_DIR,
FNM_CASEFOLD フラグは GNU の拡張である。
 
関連項目
sh(1), glob(3), scandir(3), wordexp(3), glob(7)
 
この文書について
この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は
https://www.kernel.org/doc/man-pages/ に書かれている。
 Index
- 名前
 - 
 - 書式
 - 
 - 説明
 - 
 - 返り値
 - 
 - 属性
 - 
 - 準拠
 - 
 - 関連項目
 - 
 - この文書について
 - 
 
This document was created by
man2html,
using the manual pages.
Time: 16:46:41 GMT, November 24, 2023