correct -P, $PRINTER, and DEFLP interactions. bug reported by scott.burns@labatt.com
authorderaadt <deraadt@openbsd.org>
Sat, 4 May 1996 11:52:47 +0000 (11:52 +0000)
committerderaadt <deraadt@openbsd.org>
Sat, 4 May 1996 11:52:47 +0000 (11:52 +0000)
usr.sbin/lpr/lpq/lpq.c
usr.sbin/lpr/lpr/lpr.c
usr.sbin/lpr/lprm/lprm.c
usr.sbin/lpr/pac/pac.c

index e9026bf..8559dc9 100644 (file)
@@ -104,8 +104,13 @@ main(argc, argv)
                        usage();
                }
 
-       if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+       if (printer == NULL) {
+               char *p;
+
                printer = DEFLP;
+               if ((p = getenv("PRINTER"))
+                       printer = p;
+       }
 
        for (argc -= optind, argv += optind; argc; --argc, ++argv)
                if (isdigit(argv[0][0])) {
index 037851a..bd299a8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: lpr.c,v 1.2 1996/04/21 23:40:42 deraadt Exp $ */
+/*     $OpenBSD: lpr.c,v 1.3 1996/05/04 11:52:55 deraadt Exp $ */
 /*     $NetBSD: lpr.c,v 1.10 1996/03/21 18:12:25 jtc Exp $     */
 
 /*
@@ -259,8 +259,14 @@ main(argc, argv)
                        }
                }
        }
-       if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+
+       if (printer == NULL) {
+               char *p;
+
                printer = DEFLP;
+               if ((p = getenv("PRINTER"))
+                       printer = p;
+       }
        chkprinter(printer);
        if (SC && ncopies > 1)
                fatal2("multiple copies are not allowed");
index df3a6cb..88607c2 100644 (file)
@@ -133,8 +133,13 @@ main(argc, argv)
                        }
                }
        }
-       if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+       if (printer == NULL) {
+               char *p;
+
                printer = DEFLP;
+               if ((p = getenv("PRINTER"))
+                       printer = p;
+       }
 
        rmjob();
        exit(0);
index ac8abc2..36e15f2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pac.c,v 1.3 1996/04/21 23:40:48 deraadt Exp $ */
+/*     $OpenBSD: pac.c,v 1.4 1996/05/04 11:53:05 deraadt Exp $ */
 /*     $NetBSD: pac.c,v 1.7 1996/03/21 18:21:20 jtc Exp $      */
 
 /*
@@ -169,8 +169,13 @@ fprintf(stderr,
                (void) enter(--cp);
                allflag = 0;
        }
-       if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+       if (printer == NULL) {
+               char *p;
+
                printer = DEFLP;
+               if ((p = getenv("PRINTER"))
+                       printer = p;
+       }
        if (!chkprinter(printer)) {
                printf("pac: unknown printer %s\n", printer);
                exit(2);