cups/ogonki

51 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
if test "$#" -lt "5"; then
echo "ERROR: Number of arguments ($#) is wrong" 1>&2
exit 1
fi
if test "$#" -gt "6"; then
echo "ERROR: Number of arguments ($#) is wrong" 1>&2
exit 1
fi
# Log the command line
echo ogonkify: $@ 1>&2
# Get the last parameter (which is the filename if present)
eval filename="\${$#}"
case "$CHARSET" in
iso-8859-1) CMD="cat " ;;
iso-8859-2) CMD="/usr/bin/ogonkify -AT -N " ;;
iso-8859-3) CMD="/usr/bin/ogonkify -e L3 -AT -N " ;;
iso-8859-4) CMD="/usr/bin/ogonkify -e L4 -AT -N " ;;
iso-8859-9) CMD="/usr/bin/ogonkify -e L5 -AT -N " ;;
iso-8859-10) CMD="/usr/bin/ogonkify -e L6 -AT -N " ;;
iso-8859-15) CMD="/usr/bin/ogonkify -e L9 -AT -N " ;;
*) CMD="cat " ;;
esac
if [ -e $filename ]; then
FILE_TO_PRINT=$filename;
else
FILE_TO_PRINT="";
fi
if [ -z $FILE_TO_PRINT ]; then
FILE_TO_PRINT=`mktemp -q /tmp/ogonki.XXXXXX`
if [ $? -ne 0 ]; then
echo "ERROR: Can't create temp file, exiting..." 1>&2
exit 1
fi
trap "rm -f $FILE_TO_PRINT" EXIT SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM
cat >$FILE_TO_PRINT
fi
if [ -z $FILE_TO_PRINT ]; then
eval $CMD
else
eval $CMD <$FILE_TO_PRINT
fi