home *** CD-ROM | disk | FTP | other *** search
/ HTML - Publishing on the Internet / html_cdrom.iso / tools / html / linux / check / makemenu.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-14  |  2KB  |  64 lines

  1. #!/bin/sh
  2. #
  3. # Shell script to run makemenu.awk under the best available awk interpreter,
  4. # and avoid problems of invoking old awk, if possible.  Also does options
  5. # checking.
  6. #
  7. case `type gawk` in *gawk ) awkntrp='gawk';;
  8.                         * ) case `type nawk` in *nawk ) awkntrp='nawk';;
  9.                                                     * ) awkntrp='awk';;
  10.                             esac;;
  11. esac
  12. #
  13. nonvar='NO'
  14. title='NO'
  15. for px
  16. do
  17.  case $px
  18.  in -?* ) echo "You are passing flags to the $awkntrp interpreter in argument $px" >&2
  19.           echo "(This may not be what you intended)" >&2 ;;
  20.     *=* ) if   test $nonvar = 'YES'
  21.           then echo "Error: An option=value argument $px followed" >&2
  22.                echo "a filename argument on the command line." >&2
  23.                exit 1
  24.           else
  25.             case $px
  26.             in title=* ) title='YES';;
  27.                  toc=* ) ;;
  28.            dirprefix=* ) case $px
  29.                           in */ ) ;;
  30.                               * ) echo "Warning! dirprefix= does not end with \`/'" >&2;;
  31.                          esac;;
  32.              * ) echo "Error: In the option=value argument $px, the part" >&2
  33.                  echo "before the equals sign \`=' is not a recognized option." >&2
  34.                  exit 1;;
  35.             esac
  36.           fi;;
  37.       * ) nonvar='YES';;
  38.  esac
  39. done
  40. if test $title = 'NO'
  41. then echo "No title= was specified; \"Menu for HTML files\" will be used as default" >&2
  42. fi
  43. #
  44. case ${HTMLCHEK:-"/"}
  45.     in */ ) ;;
  46.        * ) HTMLCHEK="$HTMLCHEK/";;
  47. esac
  48. if test -s ${HTMLCHEK}makemenu.awk
  49. then
  50.     echo "Making menu now... (using $awkntrp)" >&2
  51.     $awkntrp -f ${HTMLCHEK}makemenu.awk $@
  52.     if test $? -ne 0
  53.     then echo "Note: there was apparently an error in running $awkntrp" >&2
  54.          exit 1
  55.     fi
  56. else
  57.     echo "makemenu.awk is not found.  Either copy it to the current directory, or
  58. set the environment variable HTMLCHEK to the pathname where it is located.
  59. Do \`setenv HTMLCHEK /somedir/' in csh and tcsh, \`HTMLCHEK=/somedir/;
  60. export HTMLCHEK' in sh and its offspring." >&2
  61.     exit 1
  62. fi
  63. exit 0
  64.