Subject: standards/17917: lp not X/Open Issue 6 - IEEE 1003.1-2001 compliant
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ginsbach@cray.com>
List: netbsd-bugs
Date: 08/12/2002 13:34:25
>Number:         17917
>Category:       standards
>Synopsis:       lp is not X/Open or POSIX compliant
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 12 11:35:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Brian Ginsbach
>Release:        NetBSD 1.5.2, 1.5.3, current
>Organization:
Cray Inc.
>Environment:
System: NetBSD nbtest.cray.com 1.5.2 NetBSD 1.5.2 (NBTEST) #1: Wed Feb 20 03:38:32 CST 2002 ginsbach@nbtest.cray.com:/usr/src/sys/arch/i386/compile/NBTEST i386


>Description:
	According to The Open Group Base Specifications Issue 6,
	IEEE Std 1003.1-2001, "The lp utility shall write a request
	ID to the standard output, unless -s is specified. The
	format of the message is unspecified. The request ID can
	be used on systems supporting the historical cancel and
	lpstat utilities."

	This is very similar to the requirement for SUSv2. "The lp
	utility writes a request ID to the standard output, unless
	-s is specified. The format of the message is unspecified.
	This request ID can be used later to cancel (see cancel)
	or find the status (see lpstat) of the request."

	The NetBSD lp command is a shell script that calls lpr.
	The minimal set of lp options are converted in to appropriate
	lpr options.  Currently the -s lp option has no effect on
	the underlying lpr command and lp is silent with or without
	the -s.  This is not correct.

>How-To-Repeat:
	nbtest> lp testfile
	nbtest>
	nbtest> lp -s testfile
	nbtest>

>Fix:
	The solution is to add an option to lpr that prints out
	the request id.  This option can then be used by lp to
	print out "request id is n", where n is the request ID.

	nbtest> lp testfile
	request id is 10
	nbtest>
	nbtest> lp -s testfile
	nbtest>


Index: lp/lp
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/lpr/lp/lp,v
retrieving revision 1.4
diff -r1.4 lp
44a45
> reqid="-R"
60c61
< 		: ;;
---
> 		reqid="";;
74c75
< exec /usr/bin/lpr "-P${dest}" ${symlink} ${ncopies} "$@"
---
> exec /usr/bin/lpr "-P${dest}" ${reqid} ${symlink} ${ncopies} "$@"
Index: lpr/lpr.1
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/lpr/lpr/lpr.1,v
retrieving revision 1.11
diff -r1.11 lpr.1
44c44
< .Op Fl cdfghlmnprstv
---
> .Op Fl cdfghlmnprRstv
134a135,136
> .It Fl q
> Queue the print job but do not start the spooling daemon.
148a151,164
> .El
> .Pp
> Normally
> .Nm
> works silently except for diaganostic messages.  The following 
> option changes this behavior.
> .Bl -tag -width indent
> .It Fl R
> Writes a message to standard output containing the unique number which
> is used to identify this job.  This number can be used to cancel (see
> .Xr lprm 1 )
> or find the status (see
> .Xr lpq 1 )
> of the job.
Index: lpr/lpr.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/lpr/lpr/lpr.c,v
retrieving revision 1.23
diff -r1.23 lpr.c
96a97
> static int	 reqid;		/* request id */
97a99
> static int	 Rflag;		/* print request id - like POSIX lp */
154c156
< 	    ":#:1:2:3:4:C:J:P:T:U:cdfghi:lmnprstvw:")) != -1) {
---
> 	    ":#:1:2:3:4:C:J:P:RT:U:cdfghi:lmnprstvw:")) != -1) {
185a188,191
> 		case 'R':		/* print request id */
> 			Rflag++;
> 			break;
> 			
401a408,409
> 		if (Rflag)
> 			printf("request id is %d\n", reqid);
715a724
> 	reqid = n;
>Release-Note:
>Audit-Trail:
>Unformatted: