-
Notifications
You must be signed in to change notification settings - Fork 1
/
man2pdf
executable file
·58 lines (58 loc) · 1000 Bytes
/
man2pdf
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
#
# man2pdf: convert a man page to a pdf file
# syntax: man2pdf <manpage-name>
# [<directory>] (default: /Users/user/Desktop)
# [0]
#
#!/bin/bash
if [ -z "$1" ] ;
then
echo
echo 'You must specify a man page name ...'
echo
echo syntax: 'man2pdf <manpage-name> [<directory>] (default:' $HOME'/Desktop)'
echo
exit 1
else
manpage=$1
fi
if [ -z "$2" ] ;
then
dirout=.
open=1
else
dirout=$2
fi
#echo dirout is $dirout
if [ ! -d "$dirout" ]
then
echo
echo "Volume or directory" \'$dirout\' does not exist...
echo
exit 1
fi
if [ ! -z $3 ];
then
open=1
fi
man -t $manpage > $dirout/$manpage.ps 2> /dev/null
ret=$?
if [ $ret -gt 0 ] ;
then
echo
echo The \'$manpage\' man page not found: error $ret encountered ...
echo
exit 1
fi
ps2pdf $dirout/$manpage.ps $dirout/$manpage.pdf
if [ $? -eq 0 ] ;
then
rm -f $dirout/$manpage.ps
fi
echo
echo $dirout/$manpage.pdf created ...
echo
if [ $open ] ;
then
open $dirout/$manpage.pdf
fi