summaryrefslogtreecommitdiff
path: root/src/pmdas/hotproc/help.fmt
diff options
context:
space:
mode:
Diffstat (limited to 'src/pmdas/hotproc/help.fmt')
-rwxr-xr-xsrc/pmdas/hotproc/help.fmt36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/pmdas/hotproc/help.fmt b/src/pmdas/hotproc/help.fmt
new file mode 100755
index 0000000..1e44ccd
--- /dev/null
+++ b/src/pmdas/hotproc/help.fmt
@@ -0,0 +1,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() }
+'