Subject: Re: lpr -P bug (Sorry I have not gnats access)
To: None <netbsd-bugs@NetBSD.ORG>
From: Michael van Elst <mlelstv@serpens.rhein.de>
List: netbsd-bugs
Date: 04/28/1996 12:16:30
"Burns, Scott" <scott.burns@labatt.com> writes:
>if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
> printer = DEFLP;
> "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.
That's wrong. C evaluation rules will skip the assignment if the printer
variable is non-NULL. The above code can be rewritten to:
if (printer == NULL) {
printer = getenv("PRINTER");
if (printer == NULL)
printer = DEFLP;
}
Maybe now it is clearer that the variable is only reused if it had a
NULL value, i.e. no printer was specified on the command line.
>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.
Did you actually try this ? :)
Regards,
--
Michael van Elst
Internet: mlelstv@serpens.rhein.de
"A potential Snark may lurk in every tree."