blob: f63c97e79b84f2a4fc551b01525754d99e457b3c (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!@BASH@
# $Id: install-info-html,v 1.1.1.1 2002/06/10 13:21:26 espie Exp $
name=install-info-html
version=1.0
all=
index_dir=.
#
# debugging
#
debug_echo=:
#
# print usage
#
function help ()
{
cat << EOF
$name $version
Install HTML info document.
Usage: $name [OPTION]... [DOCUMENT-DIR]...
Options:
-a,--all assume all subdirectories of index to be DOCUMENT-DIRs
-d,--dir=DIR set index directory to DIR (default=.)
-D,--debug print debugging info
-h,--help this help text
-v,--version show version
EOF
}
function cleanup ()
{
$debug_echo "cleaning ($?)..."
}
trap cleanup 0 9 15
#
# Find command line options and switches
#
# "x:" x takes argument
#
options="adhvW:"
#
# ugh, "\-" is a hack to support long options
# must be in double quotes for bash-2.0
while getopts "\-:$options" O
do
$debug_echo "O: \`$O'"
$debug_echo "arg: \`$OPTARG'"
case $O in
a)
all=yes
;;
D)
[ "$debug_echo" = "echo" ] && set -x
debug_echo=echo
;;
h)
help;
exit 0
;;
v)
echo $name $version
exit 0
;;
d)
index_dir=$OPTARG
;;
# a long option!
-)
case "$OPTARG" in
a*|-a*)
all=yes
;;
de*|-de*)
[ "$debug_echo" = "echo" ] && set -x
debug_echo=echo
;;
h*|-h*)
help;
exit 0
;;
di*|-di*)
index_dir="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`"
;;
version|-version)
echo $name $version
exit 0
;;
*|-*)
echo "$0: invalid option -- \"$OPTARG\""
help;
exit -1
;;
esac
esac
done
shift `expr $OPTIND - 1`
#
# Input file name
#
if [ -z "$all" -a -z "$1" ]; then
help
echo "$name: No HTML documents given"
exit 2
fi
if [ -n "$all" -a -n "$1" ]; then
echo "$name: --all specified, ignoring DIRECTORY-DIRs"
fi
if [ -n "$all" ]; then
document_dirs=`/bin/ls -d1 $index_dir`
else
document_dirs=$*
fi
index_file=$index_dir/index.html
rm -f $index_file
echo -n "$name: Writing index: $index_file..."
# head
cat >> $index_file <<EOF
<html>
<head><title>Info documentation index</title></head>
<body>
<h1>Info documentation index</h1>
This is the directory file \`index.html' a.k.a. \`DIR', which contains the
topmost node of the HTML Info hierarchy.
<p>
This is all very much Work in Progress (WiP).
<p>
<ul>
EOF
#list
for i in $document_dirs; do
echo "<li> <a href=\"$i/$i.html\">$i</a></li>"
done >> $index_file
# foot
cat >> $index_file <<EOF
</ul>
</body>
</html>
EOF
echo
|