Subject: lpr -P bug (Sorry I have not gnats access)
To: netbsd-bugs@NetBSD.ORG <netbsd-bugs@NetBSD.ORG>
From: Burns, Scott <scott.burns@labatt.com>
List: netbsd-bugs
Date: 04/27/1996 23:36:42
Firstly, sorry I didn't submit this via Gnats as I don't have access to it.
Could someone be kind enough to do it for me if this really is considered an
error. I think I submitted this before without Gnats and it was lost...
----------------------------------------------------------------------------
----------------------------------------------------------
The following piece of code (from /usr/src/usr.sbin/lpr/lpr/lpr.c in NetBSD
V1.1 (and in current that I just checked on ftp.iastate.edu)) seems to have
a small bug:
if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
printer = DEFLP;
This code is suppose to check if the user spec'd a "lpr -P queue_to_use"
command line, if the "PRINTER=" environment variable exists, or if the site
specific "DEFLP" printer should be used.
Unfortunately if you have "PRINTER=default_queue_to_use" defined and you
have specified:
"lpr -P queue_to_use" the print job goes to the "default_queue_to_use" in
your environment variable because the of reuse of the variable "printer" in
the lpr.c code.
To fix this I think the following would work:
if ( (( env_printer = getenv("PRINTER") ) != NULL ) && ( printer == NULL ) )
{
printer = env_printer;
}
else if ( printer == NULL )
{
printer = DEFLP;
}
With this code I think you will always get the printer spec'd in -P but if
not spec'd you will get the PRINTER= if it exists, else DEFLP.
Scott
scott.burns@labatt.com