Bug 14682 - [patch] lprm(1) unaware of lp(1) Environment Variables (LPDEST)
Summary: [patch] lprm(1) unaware of lp(1) Environment Variables (LPDEST)
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Garance A Drosehn
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1999-11-03 12:00 UTC by thepinkpages
Modified: 2018-05-28 19:49 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description thepinkpages 1999-11-03 12:00:00 UTC
lp(1) allows the setting of the default printer via 
Environment Variables (LPDEST or PRINTER).
lprm(1) only recongnizes PRINTER, therefore if
the default printer is set only in LPDEST, then 
lprm(1) does not behave as expected since PRINTER
may be null(non-exsistant).

Fix: 

add LPDEST as an option to lprm(1)
or 
document this failing in lp(1) and lprm(1)
How-To-Repeat: setenv LPDEST (yourprinter)
lp (afile)
lprm -
Comment 1 marko freebsd_committer 2000-07-29 11:09:43 UTC
Responsible Changed
From-To: freebsd-doc->marko

I'll take this. 
This problem also affects lpq(1), lpr(1), and pac(8).
Comment 2 marko freebsd_committer 2000-07-31 22:19:15 UTC
Whilst investigating this problem I found in /usr/bin/lp:

	# Posix 1003.2 compliant print spooler interface.

	[snip]

	# Posix says LPDEST gets precedence over PRINTER
	dest=${LPDEST:-${PRINTER:-lp}}

So it would seem that the Right Thing(tm) to do is to make the other
programs POSIX-compliant by making them honour the LPDEST environment
variable rather than simply documenting the fact that they don't (the
manpages need updating to reflect this).


--- ./lp/lp.1.orig	Sat Jul 29 13:26:50 2000
+++ ./lp/lp.1	Sat Jul 29 13:28:32 2000
@@ -74,7 +74,11 @@
 or
 .Ev PRINTER
 .Pq with this precedence
-are taken as the destination printer.
+are taken as the destination printer. If neither
+.Ev LPDEST
+or
+.Ev PRINTER
+are set then the default line printer is used.
 .It Fl n Ar num
 Specify that
 .Ar num



--- ./lpq/lpq.1.orig	Sat Jul 29 13:10:33 2000
+++ ./lpq/lpq.1	Sat Jul 29 13:24:16 2000
@@ -61,9 +61,13 @@
 .It Fl P
 Specify a particular printer, otherwise the default
 line printer is used (or the value of the
+.Ev LPDEST
+or
 .Ev PRINTER
-variable in the
-environment). All other arguments supplied are interpreted as user
+variables in the
+environment, see the
+.Sx ENVIRONMENT
+section below). All other arguments supplied are interpreted as user
 names or job numbers to filter out only those jobs of interest.
 .It Fl l
 Information about each of the files comprising the job entry
@@ -100,9 +104,14 @@
 .Xr lpc  8
 command can be used to restart the printer daemon.
 .Sh ENVIRONMENT
-If the following environment variable exists, it is used by
-.Nm lpq :
+If the following environment variables exist, they are used by
+.Nm lpq
+(if both exist,
+.Ev LPDEST
+will be used):
 .Bl -tag -width PRINTER
+.It Ev LPDEST
+Specifies an alternate default printer.
 .It Ev PRINTER
 Specifies an alternate default printer.
 .El

--- ./lpr/lpr.1.orig	Sat Jul 29 13:29:58 2000
+++ ./lpr/lpr.1	Sat Jul 29 13:38:14 2000
@@ -119,9 +119,13 @@
 .It Fl P
 Force output to a specific printer.  Normally,
 the default printer is used (site dependent), or the value of the
-environment variable
+environment variables
+.Ev LPDEST
+or
 .Ev PRINTER
-is used.
+is used (see the
+.Sx ENVIRONMENT
+section below).
 .It Fl h
 Suppress the printing of the burst page.
 .It Fl m
@@ -233,9 +237,12 @@
 .Xr pr 1 .
 .El
 .Sh ENVIRONMENT
-If the following environment variable exists, it is used by
-.Nm Ns :
+If the following environment variables exist, they are used by
+.Nm
+(if both exist, LPDEST will be used):
 .Bl -tag -width PRINTER
+.It Ev LPDEST
+Specifies an alternate default printer.
 .It Ev PRINTER
 Specifies an alternate default printer.
 .El

--- ./lprm/lprm.1.orig	Sat Jul 29 13:39:08 2000
+++ ./lprm/lprm.1	Sat Jul 29 13:46:01 2000
@@ -59,8 +59,14 @@
 .Bl -tag -width indent
 .It Fl P Ns Ar printer
 Specify the queue associated with a specific
-.Ar printer
-(otherwise the default printer is used).
+.Ar printer ,
+otherwise the default printer is used (or the value of the
+.Ev LPDEST
+or
+.Ev PRINTER
+environment variables, see the
+.Sx ENVIRONMENT
+section below).
 .It Fl
 If a single
 .Sq Fl
@@ -106,16 +112,30 @@
 any spooling files.  If a daemon is killed, a new one is
 automatically restarted upon completion of file removals.
 .Sh ENVIRONMENT
-If the following environment variable exists, it is utilized by
-.Nm lprm .
+If the following environment variables exist, they are utilized by
+.Nm lprm
+(if both exist,
+.Ev LPDEST
+will be used).
 .Bl -tag -width PRINTER
+.It Ev LPDEST
+If the environment variable
+.Ev LPDEST
+exists,
+and a printer has not been specified with the
+.Fl P
+option,
+the default printer is assumed from 
+.Ev LPDEST .
 .It Ev PRINTER
 If the environment variable
 .Ev PRINTER
 exists,
 and a printer has not been specified with the
 .Fl P
-option,
+option, and the
+.Ev LPDEST
+environment variable does not exist,
 the default printer is assumed from 
 .Ev PRINTER .
 .El

--- ./pac/pac.8.orig	Sat Jul 29 13:46:56 2000
+++ ./pac/pac.8	Sat Jul 29 13:49:26 2000
@@ -60,8 +60,12 @@
 Accounting is done for the named printer.
 Normally, accounting is done for the default printer (site dependent) or
 the value of the environment variable
+.Ev LPDEST
+or
 .Ev PRINTER
-is used.
+is used (see the
+.Sx ENVIRONMENT
+section below).
 .It Fl c
 Cause the output to be sorted by cost; usually the
 output is sorted alphabetically by name.
@@ -85,6 +89,18 @@
 Statistics are only printed for user(s)
 .Ar name ;
 usually, statistics are printed for every user who has used any paper.
+.El
+.Sh ENVIRONMENT
+If the following environment variables exist, they are used by
+.Nm
+(if both exist,
+.Ev LPDEST
+will be used):
+.Bl -tag -width PRINTER
+.It Ev LPDEST
+Specifies an alternate default printer.
+.It Ev PRINTER
+Specifies an alternate default printer.
 .El
 .Sh FILES
 .Bl -tag -width /var/account/?_sum -compact

--- ./lpq/lpq.c.orig	Sat Jul 29 12:26:34 2000
+++ ./lpq/lpq.c	Sat Jul 29 14:26:17 2000
@@ -116,7 +116,9 @@
 			usage();
 		}
 
-	if (!aflag && printer == NULL && (printer = getenv("PRINTER")) == NULL)
+	if (!aflag && printer == NULL &&
+				!((printer = getenv("LPDEST")) != NULL ||
+				(printer = getenv("PRINTER")) != NULL))
 		printer = DEFLP;
 
 	for (argc -= optind, argv += optind; argc; --argc, ++argv)

--- ./lpr/lpr.c.orig	Sat Jul 29 12:46:14 2000
+++ ./lpr/lpr.c	Sat Jul 29 14:30:47 2000
@@ -265,7 +265,8 @@
 	argv += optind;
 	if (errs)
 		usage();
-	if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+	if (printer == NULL && !((printer = getenv("LPDEST")) != NULL ||
+				(printer = getenv("PRINTER")) != NULL))
 		printer = DEFLP;
 	chkprinter(printer, pp);
 	if (pp->no_copies && ncopies > 1)

--- ./lprm/lprm.c.orig	Sat Jul 29 12:36:51 2000
+++ ./lprm/lprm.c	Sat Jul 29 14:31:40 2000
@@ -150,7 +150,8 @@
 			}
 		}
 	}
-	if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+	if (printer == NULL && !((printer = getenv("LPDEST")) != NULL ||
+				(printer = getenv("PRINTER")) != NULL))
 		printer = DEFLP;
 
 	rmjob(printer);

--- ./pac/pac.c.orig	Sat Jul 29 13:06:32 2000
+++ ./pac/pac.c	Sat Jul 29 14:32:13 2000
@@ -173,7 +173,8 @@
 		(void) enter(--cp);
 		allflag = 0;
 	}
-	if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
+	if (printer == NULL && !((printer = getenv("LPDEST")) != NULL ||
+				(printer = getenv("PRINTER")) != NULL))
 		printer = DEFLP;
 	if (!chkprinter(printer)) {
 		printf("pac: unknown printer %s\n", printer);


-- 
  If I buy a copy of WinDelete, and it doesn't delete Windows,
  am I entitled to my money back?
________________________________________________________________
51.44°N  FreeBSD - The Power To Serve http://www.freebsd.org
2.057°W  My Webpage http://ukug.uk.freebsd.org/~mark
mailto:marko@freebsd.org                http://www.radan.com
Comment 3 Doug Barton freebsd_committer 2003-03-15 05:58:55 UTC
Responsible Changed
From-To: marko->gad


marko is no longer with us, and gad is the resident lp* expert
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:49:14 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.