Debian Codegraph @

man/man1/fstrcmp.1

raw
1 .\"
2 .\" fstrcmp - fuzzy string compare library
3 .\" Copyright (C) 2009, 2011 Peter Miller
4 .\" Written by Peter Miller <[email protected]>
5 .\"
6 .\" This program is free software; you can redistribute it and/or modify
7 .\" it under the terms of the GNU General Public License as published by
8 .\" the Free Software Foundation; either version 3 of the License, or
9 .\" (at your option) any later version.
10 .\"
11 .\" This program is distributed in the hope that it will be useful,
12 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
13 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 .\" General Public License for more details.
15 .\"
16 .\" You should have received a copy of the GNU General Public License
17 .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
18 .\"
19 .ds n) fstrcmp
20 .TH \*(n) 1
21 .SH NAME
22 fstrcmp \- fuzzy comparison of strings
23 .if require_index \{
24 .XX "fstrcmp(1)" "fuzzy comparison of strings"
25 .\}
26 .SH SYNOPSIS
27 .B \*(n)
28 [ \fB\-p\fP ]
29 .I first\[hy]string
30 .I second\[hy]string
31 .sp 0.3
32 .B \*(n)
33 \fB\-w\fP
34 .I first\[hy]string
35 .I second\[hy]string
36 .sp 0.3
37 .B \*(n)
38 \fB\-a\fP
39 .I first\[hy]file
40 .I second\[hy]file
41 .sp 0.3
42 .B \*(n)
43 .B \-s
44 .I needle
45 .IR haystack \&...
46 .sp 0.3
47 .B \*(n)
48 .B \-\-version
49 .SH DESCRIPTION
50 The \*(n) command is used to
51 make fuzzy comparisons between strings.
52 The \[lq]edit distance\[rq] between the strings is printed, with 0.0
53 meaning the strings are utterly un\[hy]alike, and 1.0 meaning the strings
54 are identical.
55 .PP
56 You may need to quote the string to insulate them from the shell.
57 .SH OPTIONS
58 The \*(n) command understands the following options:
59 .TP 8n
60 \fB\-a\fP
61 .TP 8n
62 \fB\-\-files\-as\-bytes\fP
63 This option is used to compare two files as arrays of bytes.
64 See \f[I]fmemcmp\fP(3) for more information.
65 .TP 8n
66 \fB\-p\fP
67 .TP 8n
68 \fB\-\-pair\fP
69 This option is used to compare two strings as arrays of bytes.
70 This is the default.
71 See \f[I]fstrcmp\fP(3) for more information.
72 .TP 8n
73 .B \-s
74 .TP 8n
75 .B \-\-select
76 This option is used to select the closest
77 .I needle
78 from the provided
79 .I haystack
80 alternatives.
81 The most similar (single) choice is printed.
82 If none are particularly similar, nothing is printed.
83 See \f[I]fstrcmp\fP(3) for more information.
84 See below for example.
85 .TP 8n
86 \fB\-V\fP
87 .TP 8n
88 \fB\-\-version\fP
89 This option may be used to print the version of the \*(n) command,
90 and then exit.
91 .TP 8n
92 \fB\-w\fP
93 .TP 8n
94 \fB\-\-wide\-pair\fP
95 This option is used to compare two multi\[hy]byte character strings.
96 See \f[I]fstrcoll\fP(3) for more information.
97 .SH EXIT STATUS
98 The \*(n) command exits with status 1 on any error.
99 The \*(n) command only exits with status 0 if there are no errors.
100 .SH EXAMPLE
101 The \fI\*(n) \-\-select\fP option may be used in a shell script to
102 improve error messages.
103 .RS
104 .nf
105 .ft CW
106 case "$action" in
107 start)
108 start
109 ;;
110 stop)
111 stop
112 ;;
113 restart)
114 stop
115 start
116 ;;
117 *)
118 echo "$0: action \e"$action\e" unknown" 1>&2
119 guess=`fstrcmp \-\-select "$action" stop start restart`
120 if [ "$guess" ]
121 then
122 echo "$0: did you mean \e"$guess\e" instead?" 1>&2
123 fi
124 exit 1
125 ;;
126 esac
127 .ft R
128 .fi
129 .RE
130 Thus, the error message frequently suggests the correct action
131 in the face of simple finger problems on the command line.
132 .SH SEE ALSO
133 .TP 8n
134 \f[I]fstrcmp\fP(3)
135 fuzzy comparison of strings
136 .TP 8n
137 \f[I]fstrcoll\fP(3)
138 fuzzy comparison of two multi\[hy]byte character strings
139 .TP 8n
140 \f[I]fstrcmpi\fP(3)
141 fuzzy comparison of strings, integer variation
142 .so man/man1/z_copyright.so