Subject: standards/17917: lp not X/Open Issue 6 - IEEE 1003.1-2001 compliant
To: None <>
From: None <>
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
>Originator:     Brian Ginsbach
>Release:        NetBSD 1.5.2, 1.5.3, current
Cray Inc.
System: NetBSD 1.5.2 NetBSD 1.5.2 (NBTEST) #1: Wed Feb 20 03:38:32 CST 2002 i386

	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.

	nbtest> lp testfile
	nbtest> lp -s testfile

	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> lp -s testfile

Index: lp/lp
RCS file: /cvsroot/basesrc/usr.sbin/lpr/lp/lp,v
retrieving revision 1.4
diff -r1.4 lp
> reqid="-R"
< 		: ;;
> 		reqid="";;
< 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
< .Op Fl cdfghlmnprstv
> .Op Fl cdfghlmnprRstv
> .It Fl q
> Queue the print job but do not start the spooling daemon.
> .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
> static int	 reqid;		/* request id */
> static int	 Rflag;		/* print request id - like POSIX lp */
< 	    ":#:1:2:3:4:C:J:P:T:U:cdfghi:lmnprstvw:")) != -1) {
> 	    ":#:1:2:3:4:C:J:P:RT:U:cdfghi:lmnprstvw:")) != -1) {
> 		case 'R':		/* print request id */
> 			Rflag++;
> 			break;
> 		if (Rflag)
> 			printf("request id is %d\n", reqid);
> 	reqid = n;