summaryrefslogtreecommitdiff
path: root/chinese/chm2html/files/chm.sh
diff options
context:
space:
mode:
Diffstat (limited to 'chinese/chm2html/files/chm.sh')
-rw-r--r--chinese/chm2html/files/chm.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/chinese/chm2html/files/chm.sh b/chinese/chm2html/files/chm.sh
new file mode 100644
index 000000000000..7446702e2f90
--- /dev/null
+++ b/chinese/chm2html/files/chm.sh
@@ -0,0 +1,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"
+