#!/bin/bash # set -x trap "" 1 roff="$1" post=`dirname "$1"`/`basename "$1" .ro`.ps view="gv --nowatch" # groff="$HOME/comp/src/groff-cvs/groff/test-groff -P -F$HOME/lib/roff/font" groff=groff # GROFF_FONT_PATH=$HOME/lib/fonts/DIT-edited:$HOME/lib/fonts/DIT-generated GROFF_FONT_PATH=$HOME/lib/roff/font export GROFF_FONT_PATH refresh(){ test -z "$1" && { $view "$post" & } || kill -HUP $1 } opt="" sort="no" manual="false" duplex="true" read comment options <"$roff" for option in $options do case $option in soelim) opt="$opt -s";; tbl) opt="$opt -t";; eqn) opt="$opt -e";; pic) opt="$opt -p";; refer) opt="$opt -R";; man) opt="$opt -man";; mdoc) opt="$opt -mdoc";; ms) opt="$opt -ms";; me) opt="$opt -me";; mm) opt="$opt -mm";; mom) opt="$opt -mom";; unsafe) opt="$opt -U";; land) opt="$opt -P -l";; a5) opt="$opt -P -pa5";; b5) opt="$opt -P -pb5";; c6) opt="$opt -P -pc6";; -p*) opt="$opt -P $option";; # manual) opt="$opt -P -m";; manual) manual="true";; simplex) duplex="false";; resort) sort="yes";; *) echo "unknown option \"$option\"";; esac done if test "$sort" = "yes" then "$groff" -ww -b -Tps $opt -Z "$roff" | sed -f $HOME/lib/roff/resort.sed | grops | sed -e "/%%BeginFeature: \*PageSize Default/,/%%EndFeature/d /^%%EndSetup$/i\ << /Duplex $duplex /ManualFeed $manual >> setpagedevice" \ >"$post" rm troff.sort else "$groff" -ww -b -Tps $opt "$roff" | sed -e " # 1s/$/ EPSF\\ # %%BoundingBox: 0 0 596 794/ # /%%BeginFeature: \*PageSize Default/,/%%EndFeature/d /^%%EndSetup$/i\ << /Duplex $duplex /ManualFeed $manual >> setpagedevice" \ >"$post" fi # -- ps output is like "1308677 pts/19 S 0:00.38 gv test.ps" -- # -- first item is PID, used in refresh function as $1 -- # -- [0-9] matches time and is used to exclude the grep process -- pid=`ps x | grep "[0-9] $view $post"` refresh $pid