blob: 1e44ccd8954b7814255452afbe34eaec27460382 (
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
|
#!/bin/sh
#
# Run paragraphs of help text thru fmt(1)
# Lines with tabs or double spaces are run thru fmt(1) only for that line
# source the PCP configuration environment variables
. $PCP_DIR/etc/pcp.env
tmp=`mktemp -d /tmp/pcp.XXXXXXXXX` || exit 1
trap "rm -rf $tmp; exit" 0 1 2 3 15
$PCP_AWK_PROG -v tmpfile=$tmp/fmt '
function fmt_line(l) {
print l > tmpfile
system("fmt -78 < " tmpfile) # format line(s)
close(tmpfile)
system(">" tmpfile) # truncate file
}
function format_line() {
if (line != "") {
fmt_line(line)
line = ""
}
}
BEGIN { line = "" }
/^#/ || /^@/ { format_line(); print; next }
/ / || / / { format_line(); fmt_line($0); next }
/^$/ { format_line(); print; next }
{
if (line == "")
line = $0
else
line = sprintf("%s\n%s",line,$0)
}
END { format_line() }
'
|