now using binary

This commit is contained in:
rsc 2007-03-26 20:55:47 +00:00
parent 05a4d855f1
commit 0b4084dafc

120
bin/page
View file

@ -1,120 +0,0 @@
#!/bin/sh
# BUG - Should clean up $tmp but how to know when viewer is done?
preview()
{
list=""
pwd=`pwd`
for i in "$@"
do
if [ -n "$list" ]
then
list="$list, "
fi
n=`cleanname -d $pwd $i | sed 's!/!:!g'`
list="$list\"$n\""
done
# echo run $list
echo 'tell application "Preview"
activate
open {'"$list"'}
end tell' | osascript
}
xfile()
{
if sed 1q "$1" | 9 grep '^x T '
then
echo 'troff intermediate output'
else
9 file < "$1" | sed 's/stdin: //' | tr A-Z a-z
fi
}
main()
{
case `uname` in
Darwin)
preview "$@"
;;
*)
case "`xfile $1`" in
*troff*)
tr2post "$1" | psfonts | page
;;
*pdf*)
psv $1
;;
*ps*)
psv $1
;;
*postscript*)
psv $1
;;
*)
qiv "$@"
;;
esac
;;
esac
}
case $# in
0)
tmp=/var/tmp/page.$$.tmp
cat >$tmp
type=`xfile $tmp`
case "$type" in
*troff*)
mv $tmp $tmp.tr
tmp=$tmp.tr
;;
*pdf*)
mv $tmp $tmp.pdf
tmp=$tmp.pdf
;;
*gif*)
mv $tmp $tmp.gif
tmp=$tmp.gif
;;
*jpg*)
mv $tmp $tmp.jpg
tmp=$tmp.jpg
;;
*jpeg*)
mv $tmp $tmp.jpg
tmp=$tmp.jpg
;;
*png*)
mv $tmp $tmp.png
tmp=$tmp.png
;;
*postscript*)
mv $tmp $tmp.ps
tmp=$tmp.ps
;;
*postscript*)
mv $tmp $tmp.ps
tmp=$tmp.ps
;;
*ps*)
mv $tmp $tmp.ps
tmp=$tmp.ps
;;
*)
echo 1>&2 page: unrecognized file type on standard input: $type
rm -f $tmp
exit 1
esac
main $tmp
if [ `uname` != Darwin ]
then
rm -f $tmp
fi
;;
*)
main "$@"
;;
esac