1 #!@BASH@ 2 # Id: install-info-html,v 1.3 2004/04/11 17:56:47 karl Exp 3 4 name=install-info-html 5 version=1.0 6 7 all= 8 index_dir=. 9 10 # 11 # debugging 12 # 13 debug_echo=: 14 15 16 # 17 # print usage 18 # 19 function help () 20 { 21 cat << EOF 22 $name $version 23 Install HTML info document. 24 25 Usage: $name [OPTION]... [DOCUMENT-DIR]... 26 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 34 } 35 36 37 function cleanup () 38 { 39 $debug_echo "cleaning ($?)..." 40 } 41 42 trap cleanup 0 9 15 43 44 # 45 # Find command line options and switches 46 # 47 48 # "x:" x takes argument 49 # 50 options="adhvW:" 51 # 52 # ugh, "\-" is a hack to support long options 53 # must be in double quotes for bash-2.0 54 55 while getopts "\-:$options" O 56 do 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` 108 109 # 110 # Input file name 111 # 112 if [ -z "$all" ] && [ -z "$1" ]; then 113 help 114 echo "$name: No HTML documents given" 115 exit 2 116 fi 117 118 if [ -n "$all" ] && [ -n "$1" ]; then 119 echo "$name: --all specified, ignoring DIRECTORY-DIRs" 120 fi 121 122 if [ -n "$all" ]; then 123 document_dirs=`/bin/ls -d1 $index_dir` 124 else 125 document_dirs=$* 126 fi 127 128 index_file=$index_dir/index.html 129 rm -f $index_file 130 echo -n "$name: Writing index: $index_file..." 131 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. 140 <p> 141 This is all very much Work in Progress (WiP). 142 <p> 143 <ul> 144 EOF 145 146 #list 147 for i in $document_dirs; do 148 echo "<li> <a href=\"$i/$i.html\">$i</a></li>" 149 done >> $index_file 150 151 # foot 152 cat >> $index_file <<EOF 153 </ul> 154 </body> 155 </html> 156 EOF 157 echo 158