package a2ps
severity 280370 grave
merge 267527 280370
thanks

I'm not completely sure that this bug should be grave, but I can see the
justification since right now a2ps can't print on any system that uses
lpr.  Anyway, since one of these bugs was already marked grave, I'll
change the severity on the other bug so that they can be merged.

The patch attached to 267527 didn't work with the version of getopt that I
have.  Note the output of getopt:

wanderer:~/tmp/a2ps-4.13b/debian> getopt -o d: -- -d foo testing
 -d 'foo' -- 'testing'

The parsing loop therefore has to look for and handle the -- and then stop
parsing options at that point; with the patch in 267527 applied,
a2ps-lpr-wrapper just always produced an error for me.  Here is a fixed
patch:

diff -ruNp a2ps-4.13b-pristine/debian/a2ps-lpr-wrapper 
a2ps-4.13b/debian/a2ps-lpr-wrapper
--- a2ps-4.13b-pristine/debian/a2ps-lpr-wrapper 2005-07-30 13:36:58.909469000 
-0700
+++ a2ps-4.13b/debian/a2ps-lpr-wrapper  2005-07-30 13:56:30.828310568 -0700
@@ -1,12 +1,30 @@
-#!/bin/sh
+#!/bin/bash
 #
 # a2ps-lpr-wrapper - lp/lpr wrapper script for GNU a2ps on Debian
 #
 
+TEMP=`getopt -o d: -n 'a2ps-lpr-wrapper' -- "$@"`
+PRINTER=""
+
+if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
+
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+
+while true ; do
+  case "$1" in
+    -d) PRINTER=$2; shift 2 ;;
+    --) shift; break ;;
+     *) echo "usage: a2ps-lpr-wrapper -d [printer] [files]"; exit 1 ;;
+  esac
+done
+
 # If /usr/bin/lp (from cupsys-client) exists, just use it.
 if [ -x /usr/bin/lp ]; then
-  /usr/bin/lp $*
+  if [ "x$PRINTER" != "x" ]; then d="-d $PRINTER"; else d=""; fi
+  /usr/bin/lp $d "$@"
 else
   # In case /usr/bin/lp is not available, then fall back /usr/bin/lpr.
-  /usr/bin/lpr $*
+  if [ "x$PRINTER" != "x" ]; then P="-P $PRINTER"; else P=""; fi
+  /usr/bin/lpr $P "$@"
 fi
-- 
Russ Allbery ([EMAIL PROTECTED])             <http://www.eyrie.org/~eagle/>

Reply via email to