home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / psroff / part01 / psroff.sh < prev    next >
Encoding:
Text File  |  1989-10-17  |  1.7 KB  |  92 lines

  1. :
  2. #    Copyright 1985, 1986, 1987, 1988 Chris Lewis
  3. #        All Rights Reserved
  4. #
  5. #    Permission to copy and further distribute is freely given provided 
  6. #    this copyright notice remains intact and that this software is not 
  7. #    sold for profit.
  8. #
  9. #    Project:    Generic Troff drivers
  10. #    Module:        psroff.sh
  11. #    Author:     Chris Lewis
  12. #    Specs:        troff driver
  13. #
  14. #ident  "@(#)psroff.sh: 1.15 Copyright 89/07/14 14:47:46 Chris Lewis"
  15. term=false
  16. type=`basename $0 | sed -e 's/^\(..\).*/\1/'`
  17. copies=1
  18. for i in $*
  19. do
  20.     case $i in
  21.     -X)
  22.         set -x
  23.         ;;
  24.     -t)
  25.         term=true
  26.         ;;
  27.     -T*)
  28.         device=`echo $i | sed -e 's/-T//'`
  29.         ;;
  30.     -d*)
  31.         type=`echo $i | sed -e 's/-d//'`
  32.         ;;
  33.     -n*)
  34.         copies=`echo $i | sed -e 's/-n//'`
  35.         ;;
  36.     -D | -m)
  37.         debug="$debug $i"
  38.         ;;
  39.     -)
  40.         files="$files $i"
  41.         ;;
  42.     -rL*)
  43.         eval `echo $i | sed -e 's/-rL\(..*\)\(.\)$/length=\1 prec=\2/'`
  44.         if [ -z "$length" -o -z "$prec" ]
  45.         then
  46.         echo "Bad length definition ($i) - must have value and scale" \
  47.             >&2
  48.         exit 1
  49.         fi
  50.         length="-l$length$prec"
  51.         args="$args $i"
  52.         ;;
  53.     -*)
  54.         args="$args $i"
  55.         ;;
  56.     *)
  57.         files="$files $i"
  58.         if [ ! -r $i ]
  59.         then
  60.         echo "$0: cannot open $i" >&2
  61.         exit 1
  62.         fi
  63.         ;;
  64.     esac
  65. done
  66.  
  67. if [ -x troff2ps ]
  68. then
  69.     t2=./troff2ps
  70. else
  71.     t2=%%LIBDIR%%/troff2ps
  72. fi
  73.  
  74. #    If you add a driver, you will have to add it here too:
  75. case $type in
  76.     lj | lk)        OUTPUT="%%LJOUTPUT%%" ;;
  77.     ps)        OUTPUT="%%PSOUTPUT%%" ;;
  78.     dt)        OUTPUT="%%DTOUTPUT%%" ;;
  79.     *)
  80.     echo "$0: don't understand $type drivers" >&2
  81.     exit 1
  82.     ;;
  83. esac
  84. if $term
  85. then
  86.     ( troff -t $args $files 2>&1 ) | $t2 $length -d$type $debug $device
  87.     exit $?
  88. else
  89.     eval "( troff -t $args $files 2>&1 ) | $t2 $length -d$type $debug $device $OUTPUT"
  90.     exit $?
  91. fi
  92.