lilypond-1.3.145
[lilypond.git] / buildscripts / install-info-html.sh
bloba21e9b7d8f2827814115f32821331e68b3e94bcf
1 #!@BASH@
3 name=install-info-html
4 version=1.0
6 all=
7 index_dir=.
10 # debugging
12 debug_echo=:
16 # print usage
18 function help ()
20 cat << EOF
21 $name $version
22 Install HTML info document.
24 Usage: $name [OPTION]... [DOCUMENT-DIR]...
26 Options:
27 -a,--all assume all subdirectories of index to be DOCUMENT-DIRs
28 -d,--dir=DIR set index directory to DIR (default=.)
29 -D,--debug print debugging info
30 -h,--help this help text
31 -v,--version show version
32 EOF
36 function cleanup ()
38 $debug_echo "cleaning ($?)..."
41 trap cleanup 0 9 15
44 # Find command line options and switches
47 # "x:" x takes argument
49 options="adhvW:"
51 # ugh, "\-" is a hack to support long options
52 # must be in double quotes for bash-2.0
54 while getopts "\-:$options" O
56 $debug_echo "O: \`$O'"
57 $debug_echo "arg: \`$OPTARG'"
58 case $O in
60 all=yes
63 [ "$debug_echo" = "echo" ] && set -x
64 debug_echo=echo
67 help;
68 exit 0
71 echo $name $version
72 exit 0
75 index_dir=$OPTARG
77 # a long option!
79 case "$OPTARG" in
80 a*|-a*)
81 all=yes
83 de*|-de*)
84 [ "$debug_echo" = "echo" ] && set -x
85 debug_echo=echo
87 h*|-h*)
88 help;
89 exit 0
91 di*|-di*)
92 index_dir="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`"
94 version|-version)
95 echo $name $version
96 exit 0
98 *|-*)
99 echo "$0: invalid option -- \"$OPTARG\""
100 help;
101 exit -1
103 esac
104 esac
105 done
106 shift `expr $OPTIND - 1`
109 # Input file name
111 if [ -z "$all" -a -z "$1" ]; then
112 help
113 echo "$name: No HTML documents given"
114 exit 2
117 if [ -n "$all" -a -n "$1" ]; then
118 echo "$name: --all specified, ignoring DIRECTORY-DIRs"
121 if [ -n "$all" ]; then
122 document_dirs=`/bin/ls -d1 $index_dir`
123 else
124 document_dirs=$*
127 index_file=$index_dir/index.html
128 rm -f $index_file
129 echo -n "$name: Writing index: $index_file..."
131 # head
132 cat >> $index_file <<EOF
133 <html>
134 <title>Info documentation index</title>
135 <body>
136 <h1>Info documentation index</h1>
137 This is the directory file \`index.html' a.k.a. \`DIR', which contains the
138 topmost node of the HTML Info hierarchy.
140 This is all very much Work in Progress (WiP).
142 <ul>
145 #list
146 for i in $document_dirs; do
147 echo "<li> <a href=$i/$i.html>$i</a>"
148 done >> $index_file
150 # foot
151 cat >> $index_file <<EOF
152 </ul>
153 </body>
154 </html>
156 echo