Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / texinfo / util / install-info-html
blobc4973aa7113dba8634bfc0415da72957948f5a0d
1 #!@BASH@
2 # Id: install-info-html,v 1.3 2004/04/11 17:56:47 karl Exp
4 name=install-info-html
5 version=1.0
7 all=
8 index_dir=.
11 # debugging
13 debug_echo=:
17 # print usage
19 function help ()
21         cat << EOF
22 $name $version
23 Install HTML info document.
25 Usage: $name [OPTION]... [DOCUMENT-DIR]...
27 Options:
28   -a,--all             assume all subdirectories of index to be DOCUMENT-DIRs
29   -d,--dir=DIR         set index directory to DIR (default=.)
30   -D,--debug           print debugging info
31   -h,--help            this help text
32   -v,--version         show version
33 EOF
37 function cleanup ()
39         $debug_echo "cleaning ($?)..."
42 trap cleanup 0 9 15
45 # Find command line options and switches
48 # "x:" x takes argument
50 options="adhvW:"
52 # ugh, "\-" is a hack to support long options
53 # must be in double quotes for bash-2.0
55 while getopts "\-:$options" O
57         $debug_echo "O: \`$O'"
58         $debug_echo "arg: \`$OPTARG'"
59         case $O in
60                 a)
61                         all=yes
62                         ;;
63                 D)
64                         [ "$debug_echo" = "echo" ] && set -x
65                         debug_echo=echo
66                         ;;
67                 h)
68                         help;
69                         exit 0
70                         ;;
71                 v)
72                         echo $name $version
73                         exit 0
74                         ;;
75                 d)
76                         index_dir=$OPTARG
77                         ;;
78         # a long option!
79         -)
80                 case "$OPTARG" in
81                         a*|-a*)
82                                 all=yes
83                                 ;;
84                         de*|-de*)
85                                 [ "$debug_echo" = "echo" ] && set -x
86                                 debug_echo=echo
87                                 ;;
88                         h*|-h*)
89                                 help;
90                                 exit 0
91                                 ;;
92                         di*|-di*)
93                                 index_dir="`expr \"$OPTARG\" ':' '[^=]*=\(.*\)'`"
94                                 ;;
95                         version|-version)
96                                 echo $name $version
97                                 exit 0
98                                 ;;
99                         *|-*)
100                                 echo "$0: invalid option -- \"$OPTARG\""
101                                 help;
102                                 exit -1
103                                 ;;
104                 esac
105         esac
106 done
107 shift `expr $OPTIND - 1`
110 # Input file name
112 if [ -z "$all" ] && [ -z "$1" ]; then
113         help
114         echo "$name: No HTML documents given"
115         exit 2
118 if [ -n "$all" ] && [ -n "$1" ]; then
119         echo "$name: --all specified, ignoring DIRECTORY-DIRs"
122 if [ -n "$all" ]; then
123         document_dirs=`/bin/ls -d1 $index_dir`
124 else
125         document_dirs=$*
128 index_file=$index_dir/index.html
129 rm -f $index_file
130 echo -n "$name: Writing index: $index_file..."
132 # head
133 cat >> $index_file <<EOF
134 <html>
135 <head><title>Info documentation index</title></head>
136 <body>
137 <h1>Info documentation index</h1>
138 This is the directory file \`index.html' a.k.a. \`DIR', which contains the
139 topmost node of the HTML Info hierarchy.
141 This is all very much Work in Progress (WiP).
143 <ul>
146 #list
147 for i in $document_dirs; do
148         echo "<li> <a href=\"$i/$i.html\">$i</a></li>"
149 done >> $index_file
151 # foot
152 cat >> $index_file <<EOF
153 </ul>
154 </body>
155 </html>
157 echo