-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathworkman.sh
More file actions
56 lines (53 loc) · 1.16 KB
/
workman.sh
File metadata and controls
56 lines (53 loc) · 1.16 KB
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
#! /bin/sh
# Convert manual page troff stdin to formatted .txt stdout.
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
manflags=
while
case $1 in
-*) :;;
*) false;;
esac
do
manflags="$manflags $1"
shift
done
groff="groff -dAD=l -rHY=0 $manflags -mtty-char -man -ww -P-bcou"
if ($groff) </dev/null >/dev/null 2>&1; then
$groff "$@"
elif (type mandoc && type col) >/dev/null 2>&1; then
mandoc $manflags -man "$@" | col -bx
elif (type nroff && type perl) >/dev/null 2>&1; then
printf '%s\n' '.
.\" Left-adjust and do not hyphenate.
.am TH
.na
.hy 0
..
.\" Omit internal page headers and footers.
.\" Unfortunately this also omits the starting header and ending footer,
.\" but that is the best old nroff can easily do.
.rm }H
.rm }F
.' | nroff -man - "$@" | perl -ne '
binmode STDIN, '\'':encoding(utf8)'\'';
binmode STDOUT, '\'':encoding(utf8)'\'';
chomp;
s/.\010//g;
s/\s*$//;
if (/^$/) {
$sawblank = 1;
next;
} else {
if ($sawblank && $didprint) {
print "\n";
$sawblank = 0;
}
print "$_\n";
$didprint = 1;
}
'
else
printf >&2 '%s\n' "$0: please install groff, or mandoc and col"
exit 1
fi