opts=""
printing_cmd="lpr"
-for arg in $*; do
+function cleanup-before-exit () {
+ rm ${tmp}
+}
+
+trap cleanup-before-exit EXIT
+
+for arg in "$@"; do
if [ "${arg}" == "-h" ] || [ "${arg}" == "--help" ]; then
echo "Contact <francois.fleuret@epfl.ch>"
echo "Version \$Id: print.sh,v 1.19 2006-11-10 15:53:23 fleuret Exp $"
- \rm ${tmp}
exit 0
elif [[ ${arg} == "-"* ]]; then
# else, it is a filename to print
- if [ -e ${arg} ]; then
+ if [ -e "${arg}" ]; then
- TYPE=$(file -L ${arg})
+ TYPE=$(file -L "${arg}")
noprint=""
case $TYPE in
*"image data"*)
- convert ${arg} ps:${tmp}
+ convert "${arg}" ps:${tmp}
;;
*"TeX DVI"*)
- dvips -o ${tmp} ${arg}
+ dvips -o ${tmp} "${arg}"
;;
*"FIG image"*)
- fig2dev -L ps ${arg} > ${tmp}
+ fig2dev -L ps "${arg}" > ${tmp}
;;
*"PostScript"*)
- cp ${arg} ${tmp}
+ cp "${arg}" ${tmp}
;;
*"PDF"*)
- pdf2ps ${arg} ${tmp}
+ pdf2ps "${arg}" ${tmp}
;;
*" text"*)
- # a2ps -B -R --columns=1 -f 8 -o ${tmp} ${arg}
- a2ps --user-option=lp -o ${tmp} ${arg}
+ # a2ps -B -R --columns=1 -f 8 -o ${tmp} "${arg}"
+ # if isutf8 -q ${tmp}; then
+ # echo "Can not print uf8 text."
+ # exit 1
+ # else
+ a2ps --media=A4 --user-option=lp -o ${tmp} "${arg}"
+ # fi
;;
*"gzip compressed"*)
echo "Unzipping "
- zcat ${arg} > ${tmp}
+ zcat "${arg}" > ${tmp}
noprint=1
$0 ${opts} ${tmp}
;;
;;
*)
echo "Unknown option $f"
- \rm ${tmp}
exit 1;;
esac
done
done
-\rm ${tmp}
-
if [[ ${show_queue} ]]; then
lpq
fi