blob: 7446702e2f90698cd16e9096c740efe0bcb8db33 (
plain) (
blame)
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
|
#!/bin/sh
# chm.sh
if [ -z "$1" ]; then
echo "file not specified"
exit 1;
fi
if [ ! -s "$1" ]; then
echo "file not exist: $1"
exit 1;
fi
which="/usr/bin/which"
# get full path or ./ of this command
# then, trace back the symbolic link
prefix=`$which $0`
while [ -h "$prefix" ]; do
lnk_to=`/bin/ls -l "$prefix" | awk '{print $NF}'`
if echo $lnk_to | grep "^/" >& /dev/null; then
prefix=$lnk_to
else
prefix=${prefix%/*}/$lnk_to
fi
done
prefix=${prefix%/*}
chm2html="$prefix/chm2html"
hhc2html="$prefix/hhc2html.pl"
for f in "$chm2html" "$hhc2html"; do
if [ ! -s "$f" ]; then
echo "${0##*/}: can not execute program '$f'"
exit 1
fi
done
chmtmp="/tmp/chm-$$"
contents="$chmtmp/chm-$$.html"
"$chm2html" < "$1" "$chmtmp"
"$hhc2html" "$chmtmp"/`ls "$chmtmp" | grep '\.hhc$'` > "$contents"
mozilla "$contents"
|