home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / GENMAN.ZIP / GENMAN next >
Text File  |  1993-03-13  |  1KB  |  74 lines

  1. #!/bin/sh
  2. #
  3. # This shell script converts a c++ header file to a man page
  4. # using the genman.awk program.
  5. #
  6. # Options supported are:
  7. #        -t            produces troff output, default is ascii
  8. #        -s            uses the program gmtime instead of ls -l
  9. #                      to get the modify time of the file
  10. #        -o file       output file name, default is stdout
  11. #
  12. set -e
  13.  
  14. # Set the variable XX to be the path where you have placed the file
  15. # genman.awk and program gmtime.
  16. #XX=/usr/local/bin
  17. XX=.
  18.  
  19. # Set the AWK variable to the name and/or path of the version of awk
  20. # you use.
  21. AWK=gawk
  22.  
  23.  
  24. # Get the name of the shell script
  25. prog=$0
  26.  
  27. #
  28. # Process the command line switches
  29. #
  30. opt_t=""
  31. opt_s=""
  32. opt_o=""
  33. file=""
  34. gmtime=$XX/gmtime
  35. while test -n "$1"
  36. do
  37.     case $1 in
  38.     -t)
  39.         opt_t="device=troff";;
  40.     -s)
  41.         opt_s="mtime=$gmtime";;
  42.     -o)
  43.         opt_o=$2
  44.         shift;;
  45.     -*)
  46.         echo "$prog: bad option $1"
  47.         exit 1;;
  48.     *)
  49.         file=$1;;
  50.     esac
  51.     shift
  52. done
  53.  
  54. # Print out the usage message if an input file was not specified
  55. if test ! -n "$file"
  56. then
  57.     echo "usage: $prog [-s -t -o file] filename"
  58.     exit 1;
  59. fi
  60.  
  61. # See if they want to output to a particular file
  62. if test -n "$opt_o"
  63. then
  64.     # make sure the input and output file are not the same
  65.     if test $opt_o = $file
  66.     then
  67.         echo "$prog: input and output file are the same, $file"
  68.         exit 1
  69.     fi
  70.     $AWK -f $XX/genman.awk $opt_t $opt_s $file > $opt_o
  71. else
  72.     $AWK -f $XX/genman.awk $opt_t $opt_s $file
  73. fi
  74.