Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# |
3 |
# Copyright (c) 2011 Alexandre Rostovtsev <tetromino@gmail.com> |
4 |
# |
5 |
# This program is free software; you can redistribute it and/or |
6 |
# modify it under the terms of the GNU General Public License as |
7 |
# published by the Free Software Foundation; either version 2 of the |
8 |
# License, or (at your option) any later version. |
9 |
# |
10 |
# This program is distributed in the hope that it will be useful, |
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 |
# General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public |
16 |
# License along with this program; if not, write to the |
17 |
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 |
# Boston, MA 02110-1301, USA. |
19 |
# |
20 |
### |
21 |
# |
22 |
# Process the requested compressed source nroff file and output groff |
23 |
# intermediate format. |
24 |
# |
25 |
|
26 |
filename=$1 |
27 |
|
28 |
if [ -z ${filename} ] ; then |
29 |
echo "Usage: yelp-groff [FILE]" >&2 |
30 |
echo "Process a man FILE and output groff intermediate format." |
31 |
exit 1 |
32 |
fi |
33 |
|
34 |
# If "man -Z -Tutf8 -EUTF-8" works (i.e. if man is man-db), use that. |
35 |
man -Z -Tutf8 -EUTF-8 ${filename} 2>/dev/null && exit 0 |
36 |
|
37 |
# Otherwise, manually uncompress the file ... |
38 |
cat="cat" |
39 |
case ${filename} in |
40 |
*.bz2) cat="bzip2 -c -d" ;; |
41 |
*.gz) cat="gunzip -c" ;; |
42 |
*.lzma) cat="unlzma -c -d" ;; |
43 |
*.xz) cat="unxz -c" ;; |
44 |
*.Z) cat="zcat" ;; |
45 |
esac |
46 |
|
47 |
# ... and run groff to get the intermediate format; preprocess with tbl |
48 |
# unless MANROFFSEQ is defined. |
49 |
${cat} ${filename} | groff -${MANROFFSEQ:-t} -man -Z -Tutf8 |