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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
#!/bin/bash
# Copyright 2019 makepost <makepost@firemail.cc>
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
mkdir -p banana/man{1,3,5}
# Can't/shouldn't write to /usr/share/man so use -M to change path
MAN="man -M banana"
echo one | bzip2 >banana/man1/numbers.1.bz2
echo three | gzip >banana/man3/numbers.3.gz
echo five > banana/man5/numbers.5
testing "man" "$MAN numbers" " one\n\n" "" ""
testing "man.section" "$MAN numbers.3" " three\n\n" "" ""
testing "section man" "$MAN 5 numbers" " five\n\n" "" ""
testing "/" "$MAN /" "" "" "" # Regression guard for !suf in zopen
cat >banana/man1/toybox.1 <<EOF
.TP
.PD 0
.B \\-F
.TP
.PD
.B \\-\\^\\-foo\\-bar
Does something.
.TP
.PD 0
.B \\-\\-no\\-alias
Has no alias.
EOF
testing "gawk alias" "$MAN toybox" " -F\n --foo-bar Does something.\n\n --no-alias Has no alias.\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
\\fBsh\\fR-compatible
\\fIKorn\\fP
EOF
testing "bash bold,ita" "$MAN toybox" " sh-compatible Korn\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
quoted \\(aqstring\\(aq
\\(dqserver\\(dq
Don\\(cq\\&t
EOF
testing "bash,rsync quote" "$MAN toybox" " quoted 'string' \"server\" Don't\n\n" "" ""
echo "\\*(lq\\-\\^\\-\\*(rq" >banana/man1/toybox.1
testing "gawk quote" "$MAN toybox" " \"--\"\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
.IP \\(bu
[\\fB|\\fP\\(bv\\fB|&\\fP]
EOF
testing "bash symbol" "$MAN toybox" " * [|||&]\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
\\&\\fBfflush(...)\\fR
\\f(CW$ ssh ...\\fP
EOF
testing "gawk,rsync fancy" "$MAN toybox" " fflush(...) $ ssh ...\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
"\\eC\\-x\\eC\\-r": re\\-read
must be \\(>= 1
EOF
testing "bash escape" "$MAN toybox" " \"\C-x\C-r\": re-read must be >= 1\n\n" "" ""
echo "\\*(AK language. The \\*(PX standard" >banana/man1/toybox.1
testing "gawk var" "$MAN toybox" " #AK language. The #PX standard\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
If set to
.BR On ,
(...)
EOF
testing "bash boldpunct" "$MAN toybox" " If set to On, (...)\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
.IP \\fB\$endif\\fP
(...)
.IP \\fB\$else\\fP
(...)
.IP \\fB\$include\\fP
EOF
testing "bash list" "$MAN toybox" " \$endif (...)\n\n \$else (...)\n\n \$include\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
asynchronously (in the
.IR background ),
it prints
EOF
testing "bash itapunct" "$MAN toybox" " asynchronously (in the background), it prints\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
(...)
.B Bash
is
EOF
testing "bash bold" "$MAN toybox" " (...) Bash is\n\n" "" ""
# TODO: Unquote.
cat >banana/man1/toybox.1 <<EOF
.PD 0
.BI \\-f " program-file"
.TP
EOF
testing "gawk boldita" "$MAN toybox" " -f \" program-file\"\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
same format as
.FN /etc/hosts
(...)
EOF
testing "bash filename" "$MAN toybox" " same format as /etc/hosts (...)\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
The
.I Internal Field Separator
that is used
EOF
testing "bash ita" "$MAN toybox" " The Internal Field Separator that is used\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
.if n Copyright (C) 2019
.if t Copyright \\(co 2019
EOF
testing "bash nroff" "$MAN toybox" " Copyright (C) 2019\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
.EX
#include <stdio.h>
#include <stdlib.h>
.EE
EOF
testing "stat example" "$MAN toybox" "#include <stdio.h>\n#include <stdlib.h>\n\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
(...)
.PP
(...)
EOF
testing "bash paragraph" "$MAN toybox" " (...)\n\n (...)\n\n" "" ""
# TODO: Find some command I saw that has a different see below.
cat >banana/man1/toybox.1 <<EOF
(see
.SM
.B INVOCATION
below)
EOF
testing "bash small" "$MAN toybox" " (see INVOCATION below)\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
(...)
.SH "SHELL GRAMMAR"
.SS Simple Commands
.PP
(...)
EOF
testing "bash section" "$MAN toybox" " (...)\n\n\"SHELL GRAMMAR\"\n\nSimple Commands\n\n (...)\n\n" "" ""
echo ".so man1/last.1" >banana/man1/toybox.1
testing "lastb" "$MAN toybox" "See last.1\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
.TH TOYBOX 1 "Apr 13 2019" "Project Organization" "Document Name"
.PP
.TH "TOYBOX" "1" "04/13/2019" "Toybox 0\\&.8\\&.0" "Toybox Manual"
EOF
testing "gawk,git head" "$MAN toybox" "TOYBOX 1 Apr 13 2019 Project Organization Document Name \n\n TOYBOX 1 04/13/2019 Toybox 0.8.0 Toybox Manual \n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
(...)
.PP
.PD 0
.TP 10
.B \\-c
If the
.B \\-c
option is present
EOF
testing "bash table" "$MAN toybox" " (...)\n\n -c If the -c option is present\n\n" "" ""
cat >banana/man1/toybox.1 <<EOF
.de FN
.sp
.RE
'\" t
EOF
testing "bash,git garbage" "$MAN toybox" "" "" ""
# "bash,git garbage" from above has no content, -k skips it.
bzip2 >banana/man1/numbers.1.bz2 <<EOF
.TH NUMBERS 1 "2019 Apr 28" "Toybox Manual"
.SH NAME
man \- test -k
.SH ANOTHER SECTION
.so noop.1
Skip this text.
EOF
echo "No dash." | gzip >banana/man3/numbers.3.gz
echo .so man1/numbers.1 >banana/man5/numbers.5
testing "-k ." "$MAN -k ." "numbers.1.bz2 - test -k\nnumbers.3.gz - No dash.\nnumbers.5 - See numbers.1\n" "" ""
testing "-k -k" "$MAN -k -k" "numbers.1.bz2 - test -k\n" "" ""
testing "-k d.*h" "$MAN -k 'd.*h'" "numbers.3.gz - No dash.\n" "" ""
testing "-k ers.1" "$MAN -k ers.1" "numbers.1.bz2 - test -k\nnumbers.5 - See numbers.1\n" "" ""
mkdir -p walrus/man1
echo Local development override. | bzip2 >walrus/man1/numbers.1.bz2
testing "-M /dir:/dir0" "man -M walrus:banana numbers" " Local development override.\n\n" "" ""
testing "-M /dir:/dir0 -k ." "man -M walrus:banana -k ." "numbers.1.bz2 - Local development override.\nnumbers.1.bz2 - test -k\nnumbers.3.gz - No dash.\nnumbers.5 - See numbers.1\n" "" ""
testing "-M '' x" "man -M '' numbers 2>&1" "man: no numbers\n" "" ""
testing "-M '' 1 x" "man -M '' 1 numbers 2>&1" "man: section 1 no numbers\n" "" ""
testing "-M '' -k ." "man -M '' -k ." "" "" ""
# TODO: emerge section header newline
# TODO: fdm,man-pages man1p/, .nf, rare tags
rm -rf banana walrus
|