-
Notifications
You must be signed in to change notification settings - Fork 0
/
section.1.in
338 lines (321 loc) · 7.96 KB
/
section.1.in
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
.TH section 1 "@DATE@" @VERSION@ "print indented sections"
.SH NAME
section \- print indented text sections selected via matching a pattern
.SH SYNOPSIS
.B section
.I [OPTIONS] PATTERN [FILE...]
.SH DESCRIPTION
The
.B section
filter searches for
.I PATTERN
in each
.I FILE
(or standard input if no
.I FILE
is given), and prints the sections selected by matching lines
together with the chosen section algorithm variant
to standard output.
.P
A section comprises all deeper indented lines directly following the
starting line of the section.
The starting line of a section can also be called the section
.IR header .
.P
By default, sections are started by lines matching the
.IR PATTERN .
.P
By default,
.I PATTERN
is a regular expression, see section
.B "REGULAR EXPRESSIONS"
below.
.SH OPTIONS
Options can be used to modify the operation of
.BR section .
.B section
uses Go's
.I flag
package for option processing.
.P
Using the two character sequence
.B \-\-
(two hyphens) in an option position ends option processing.
This allows the
.I PATTERN
to start with a hyphen.
.SS Print information about the section binary:
.TP
.SS \-h, \-\-help
Write a help message to standard output.
.TP
.SS \-V, \-\-version
Write version information to standard output.
.SS Use a non-default section algorithm variant:
The
.B section
filter can use one of several ways to determine the start of a selected section.
By default,
sections start with a line that matches the
.IR PATTERN .
.TP
.SS \-\-enclosing
Sections enclose the line matching the
.IR PATTERN .
Each section starts at the last line preceding the line matching the
.I PATTERN
with less indentation.
If no such line exists, the section starts with the line matching the
.IR PATTERN .
This option has no effect when combined with the
.B \-\-top\-level
option.
.TP
.SS \-\-top\-level
Sections always start from the
.I top
.IR level ,
i.e., the minimum indentation level, instead of from the line matching the
.IR PATTERN .
A line matching the
.I PATTERN
selects the complete top level section.
.SS Control pattern matching:
.TP
.SS \-F, \-\-fixed\-string
Indicate that the
.I PATTERN
shall be interpreted as a fixed string, not as a regular expression.
.TP
.SS \-i, \-\-ignore\-case
Ignore case distinctions for pattern matching,
so that characters that differ only in case match each other.
.TP
.SS \-\-invert\-match
Match sections
.B not
selected with the
.IR PATTERN .
.SS Control section boundary determination:
Section boundary determination is based on matching the
.I PATTERN
and the indentation level of lines.
.P
Specific lines can be ignored for section boundary determination.
Ignored lines are not checked for matching the
.IR PATTERN .
Therefore they do not select a section.
The indentation level of ignored lines is not considered either,
therefore sections always continue across them.
.TP
.SS \-\-ignore\-blank
Ignore blank lines when determining section boundaries.
.TP
.SS \-\-ignore\-re IGNORE_RE
Ignore lines matching
.I IGNORE_RE
when determining section boundaries.
The
.B \-\-ignore\-blank
option overrides the
.B \-\-ignore\-re
option.
.P
By default, leading space and tab characters constitute the indentation
of a line.
Indentation depth determines which lines form a section.
.TP
.SS \-\-indent\-re INDENT_RE
Use non-default regular expression
.I INDENT_RE
to describe indentation.
The
.B \-\-yaml\-seq\-indent
option overrides this.
.TP
.SS \-\-tab\-size SIZE
Tab characters inside the indentation increase the indentation depth to
the value of the next tab stop.
Each tab stop is at a character position that is an integer multiple of
.IR SIZE,
starting with character position
.IR SIZE.
The default value of
.I SIZE
is 8.
.IP
Setting
.I SIZE
to 1 results in treating tab characters identically to space characters.
.TP
.SS \-\-yaml\-seq\-indent
Accept trailing YAML sequence (list) indentation in addition to white space
based indentation.
This results in considering a YAML sequence used as a value in a YAML mapping
as further indented than the key,
even if the
.I dash
has the same indentation depth as the key.
.SS Select additional lines:
.TP
.SS \-\-begin
Select all lines following the first line selected by the chosen section
algorithm variant.
If multiple
.IR FILE s
are given,
each
.I FILE
is considered independently.
.TP
.SS \-\-headers
In addition to the sections selected according to the chosen algorithm,
also select starting lines (headers) of enclosing sections,
up to the top level.
This option has no effect when combined with the
.B \-\-top\-level
option.
.SS Control output contents:
.TP
.SS \-\-omit
Omit (exclude) matched sections,
print everything else instead.
.TP
.SS \-\-omit\-ignored
Do not print lines that are ignored when determining section boundaries.
.TP
.SS \-q, \-\-quiet, \-\-silent
Suppress all normal output.
The exit code can be used to determine if the
.I PATTERN
was matched or not, or if an error occurred.
Error messages are still printed.
.SS Control output format:
.TP
.SS \-\-label LABEL
Use
.I LABEL
instead of the default of
.B (standard input)
in place of a file name for data from standard input when the
.B \-\-with\-filename
option is given.
.TP
.SS \-n, \-\-line\-number
Prefix each output line with the line number in the respective input file,
followed by the prefix delimiter.
The line number is added after the file name when both options
.B \-\-line\-number
and
.B \-\-with\-filename
are given.
.TP
.SS \-\-prefix\-delimiter DELIMITER
Use the given
.I DELIMITER
instead of the default of a colon
.RB ( : )
as prefix delimiter.
.I DELIMITER
need not be a single character.
.TP
.SS \-\-separator
Print a separator line between matched sections.
This allows distinguishing separate sections in the output independent of the
indentation of individual lines.
The output produced when using this option is a simple form of stanza format
without line continuations.
.IP
When used together with
.BR \-\-omit ,
consecutively omitted sections are indicated by a single separator line.
.TP
.SS \-\-separator\-string SEPARATOR
Use the given
.I SEPARATOR
instead of the default of two ASCII hyphen characters
.RB ( \-\- )
when printing section separators.
A newline is printed after the separator string.
.TP
.SS \-\-with\-filename
Prefix each output line with the file name, followed by the prefix delimiter.
The file name is added in front of the line number when both options
.B \-\-with\-filename
and
.B \-\-line\-number
are given.
.SH "REGULAR EXPRESSIONS"
.B section
uses Go's
.I regexp
package, and thus understands the
.I RE2
syntax.
.SH EXIT STATUS
.IP \(bu
0, if at least one line matched the
.I PATTERN
.IP \(bu
1, if no line matched the
.I PATTERN
.IP \(bu
2, if an error occurred
.SH "BUGS AND LIMITATIONS"
.IP \(bu
The maxmimum line size supported by
.B section
is
.IR "512 MiB" .
.IP \(bu
Regular expressions are limited to those supported by Go's
.I regexp
package.
.IP \(bu
Options are implemented with Go's
.I flag
package.
Thus single character options cannot be combined,
options longer than a single character cannot be abbreviated,
and all options can be started by either a single or a double hyphen.
Additionally, all options must come before the first non-option
argument (i.e., the
.IR PATTERN ).
.IP \(bu
YAML sequences are not handled well, because
.B section
does not parse the YAML format.
Giving the
.B \-\-yaml\-seq\-indent
option does not change this.
The structure created by YAML sequence indicators is ignored by
.BR section .
.B section
always uses indentation depth to determine sections.
.SH AUTHOR
.B section
was written by Erik Auerswald <auerswal@unix\-ag.uni\-kl.de>.
.SH COPYRIGHT
Copyright \(co @CRYEARS@ Erik Auerswald.
License GPLv3+: GNU GPL version 3 or later
.UR https://gnu.org/licenses/gpl.html
.UE
.P
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
.SH "SEE ALSO"
.BR awk (1),
.BR grep (1),
.BR expand (1),
.BR unexpand (1),
.P
.B go doc
.IR flag ,
.B go doc
.IR regexp ,
.P
.UR https://github.com/google/re2/wiki/Syntax
.UE ,
.P
.UR https://www.unix\-ag.uni\-kl.de/~auerswal/section/
.UE