/usr/bin/simpleprinterfilterdebug
#!/bin/sh
# A very simple printer filter for debugging.
# This script was written by Stephan Seidl, no copyright is claimed.
# It is offered as-is, without any warranty.
# This script is in the public domain; do with it what you wish.
#set -x
PATH="/bin:/usr/bin:${PATH}"
export PATH
basename=`basename $0`
tempfile1=`mktemp -q /tmp/spfd1XXXXXXX` || exit 1
tempfile2=`mktemp -q /tmp/spfd2XXXXXXX` || exit 1
trap "rm -f ${tempfile1} ${tempfile2} ${tempfile1}~ ${tempfile2}~" EXIT SIGHUP SIGINT SIGQUIT SIGTERM
cat > ${tempfile1}
u0=""
u1=""
h0=""
h1=""
f0=""
f1=""
z0=""
for word in ${@} ; do
case "${word}" in
-L?* ) u0=`echo ${word} | sed 's,^-L,,'` ;;
-n?* ) u1=`echo ${word} | sed 's,^-n,,'` ;;
-H?* ) h0=`echo ${word} | sed 's,^-H,,'` ;;
-h?* ) h1=`echo ${word} | sed 's,^-h,,'` ;;
-J?* ) f0=`echo ${word} | sed 's,^-J,,'` ;;
-f?* ) f1=`echo ${word} | sed 's,^-f,,'` ;;
-Z?* ) z0=`echo ${word} | sed 's,^-Z,,'` ;;
esac
done
test -z "${u0}" && u0="${u1}"
test -z "${h0}" && h0="${h1}"
test -z "${f0}" && f0="${f1}"
test -z "${f0}" && f0="(stdin)"
duplex="1"
zaux="${z0}"
while :; do
test -z "${zaux}" && break || :
echo "${zaux}" | grep ',' >/dev/null && : || zaux="${zaux},"
zhdr=`echo "${zaux}" | cut -d',' -f1`
zaux=`echo "${zaux}" | sed 's@^ *'"${zhdr}"' *,@@'`
echo "${zhdr}" | grep '^ *simplex *$' >/dev/null && duplex="0" || :
echo "${zhdr}" | grep '^ *duplex *$' >/dev/null && duplex="1" || :
done
unset zhdr zaux
cp ${tempfile1} ${tempfile2}
cat ${tempfile2}
rm -f ${tempfile1} ${tempfile2} ${tempfile1}~ ${tempfile2}~
exit 0
Stephan K.H. Seidl