summaryrefslogtreecommitdiff
path: root/support/tgrind/sysv/tgrind.sh
blob: a5cf61097f724ca7ff9a22e0e8c2aaaca08f9959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
# Script to grind nice program listings using TeX.
#
# written Feb, 1985 by Van Jacobson, Lawrence Berkeley Laboratory (adapted
# from the 4.2bsd "vgrind" script).
#
# Translated to Bourne Shell, March 1987, Lou Salkind, New York University
#
# Since TeX output handling is site dependent, you'll have to edit this
# file to get output to your local typesetting device(s).  Our site uses
# the flags "-v" (versatec output), "-q" (qms output) and "-o" (keep dvi file)
# to route output.  Put something appropriate to your site at the "PUT OUTPUT
# HANDLING..." comment at the end of this script.  If you've already dealt
# with this in your local tex command, just change the -v/q/k (or whatever)
# cases in the first "switch" to set variable "texoptions" appropriately.
#
b=/usr/local/lib/tfontedpr
tex=/usr/local/bin/tex
options=
texoptions=
files=
head=""
format=""
output="dvi"
outputfile=tgrind.dvi
expecting=filename

for A do
    case $A in

    -d)
	expecting=doptions ;;
			
    -f)
	format="Y" ;;

    -h)
	expecting=head ;;
			
    -o)
	output=dvi
	expecting=outputfile ;;

# some sample devices...
    -v)
	output="ver" ;;

    -q)
	output="qms" ;;

    -*)
	options="$options $A" ;;

    *)
	case $expecting in
	outputfile)
		outputfile="$A" ;;
	head)
		head="$A" ;;
	doptions)
		options="$options -d $A" ;;
	filename)
		files="$files $A" ;;
	esac
	expecting=filename ;;
    esac
done

if [ "$format" = "Y" ]; then
    if [ "$head" != "" ]; then
	$b $options -h "$head" $files
    else
	$b $options $files
    fi
    exit 0
fi

trap 'rm -f tgrnd$$.tex tgrnd$$.dvi tgrnd$$.log' 0 2 3 15

if [ "$head" != "" ]; then
    $b $options -h "$head" $files >tgrnd$$.tex
else
    $b $options $files >tgrnd$$.tex
fi
$tex $texoptions tgrnd$$.tex

# PUT OUTPUT HANDLING COMMANDS HERE.
case $output in
ver)
	;;
qms)
	;;
dvi)
#	if [ `expr $outputfile : '/*'` -eq 0 ]; then
#		outputfile=$mydir/$outputfile
#	fi
	mv tgrnd$$.dvi $outputfile
	;;
esac