Merge from vendor branch TEXINFO:
[dragonfly.git] / share / examples / printing / ifhp
1 #!/bin/sh
2 #
3 #  ifhp - Print Ghostscript-simulated PostScript on a DesJet 500
4 #  Installed in /usr/local/libexec/hpif
5
6 #
7 #  Treat LF as CR+LF:
8 #
9 printf "\033&k2G" || exit 2
10
11 #
12 #  Read first two characters of the file
13 #
14 read first_line
15 first_two_chars=`expr "$first_line" : '\(..\)'`
16
17 if [ "$first_two_chars" = "%!" ]; then
18     #
19     #  It is PostScript; use Ghostscript to scan-convert and print it
20     #
21     /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \
22         && exit 0
23
24 else
25     #
26     #  Plain text or HP/PCL, so just print it directly; print a form
27     #  at the end to eject the last page.
28     #
29     echo "$first_line" && cat && printf "\f" && exit 0
30 fi
31
32 exit 2