home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume10 / roff17 / roff < prev   
Encoding:
Text File  |  1990-01-19  |  1.1 KB  |  55 lines

  1. #!/bin/sh
  2. # roff by Brian E. Litzinger
  3. # $Header: roff,v 1.7 90/01/17 00:19:18 brian Exp $
  4. # Contributing Authors:
  5. #     Jeff Goldstein, Svante Lindahl, Barry Schwartz
  6. #
  7. # Usage:  roff [ -p prefix ] [ options ] file-name ...
  8. # The troff-prefix is the first part of the troff command name, the
  9. # second part being "roff".  For example, type
  10. #    roff -f ps file
  11. # to run the file through psroff and the appropriate filters and macros.
  12.  
  13. TROFF=eroff
  14. PREFIX=e
  15. TMP=/tmp/roff$$
  16. if [ $# -lt 1 ] ; then
  17.     echo "Usage:  `basename $0` [ -p prefix ] [options] files"
  18.     exit 2
  19. fi
  20. while [ -n "$1" ] ; do
  21.     case "$1" in
  22.     -p)
  23.         shift
  24.         PREFIX=$1
  25.     ;;
  26.     -*)
  27.         args="$args $1"
  28.     ;;
  29.     *)
  30.         command_line="`sed -e 1q $1`"
  31.         b="`echo $command_line | cut -f2 -d' '`"
  32.         if [ "$b" != "exec" ] ; then
  33.         echo "$1 not roff format file!"
  34.         exit 2
  35.         fi
  36.         command="`echo $command_line | cut -f3- -d' '"
  37.         d="sed -e 1d $1 |"
  38.         for i in $command ; do
  39.         if [ "$i" = '$F' ] ; then
  40.             true
  41.         else
  42.             if [ "$i" = "$TROFF" ] ; then
  43.             d="$d ${PREFIX}roff $args"
  44.             else
  45.             d="$d $i"
  46.             fi
  47.         fi
  48.         done
  49.         #echo $d
  50.         eval $d
  51.     ;;
  52.     esac
  53.     shift
  54. done
  55.