summaryrefslogtreecommitdiff
path: root/man/2/filepat
blob: 0f8eff5bbc8a49cd5cdee17dc2940b4b4e29443c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.TH FILEPAT 2
.SH NAME
filepat: expand, match \- file pattern matching
.SH SYNOPSIS
.EX
include "filepat.m";
filepat := load Filepat Filepat->PATH;

expand:  fn(pat: string): list of string;
match:   fn(pat, name: string): int;
.EE
.SH DESCRIPTION
.B Expand
builds a list of file names in alphabetical order that match
the pattern
.IR pat .
The pattern is tokenised using
.B /
as a delimiter.
.PP
.B Match
returns 1 if
.I name
matches the pattern
.IR pat ,
and 0 otherwise.
.PP
The
.I pat
passed to
.B match
and
.B expand
may include combinations of the special characters
.BR * ,
.BR ? ,
.BR [ ,
and
.BR ] .
.PP
The asterisk
.B *
matches a string of zero or more characters.
.PP
The query
.B ?
matches any single character.
.PP
The notation
.BI [ s ]\f1,
where
.I s
is a nonempty string, matches any
single character in
.IR s .
The notation
.BI [^ s ]\f1,
where
.IR s
is a nonempty string, matches any
single character not in
.IR s .
The characters
.BR * ,
.BR ? ,
and
.BR [
have no special meaning within s.
.PP
If any character
is preceded by the character
.BR \e ,
that character loses any special meaning
and is interpreted literally.
.SH SOURCE
.B /appl/lib/filepat.b
.SH SEE ALSO
.IR sys-tokenize (2),
.IR readdir (2)
.IR regex (2)