Subject: bin/7923: bin: pkg_create says @display will use more(1), pkg_add doesn't
To: None <gnats-bugs@gnats.netbsd.org>
From: None <eric@apps2go.com>
List: netbsd-bugs
Date: 07/05/1999 20:22:54
>Number:         7923
>Category:       bin
>Synopsis:       pkg_create says @display will use more, but pkg_add doesn't
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul  5 20:20:03 1999
>Last-Modified:
>Originator:     Eric Schnoebelen
>Organization:
	Software2Go, LLC
>Release:        1.4-Release 4 July, 1999
>Environment:
	
System: NetBSD mr-ed 1.4 NetBSD 1.4 (GENERIC) #1: Sat May 8 11:37:01 PDT 1999 ross@netbsd.org:/usr/src/sys/arch/alpha/compile/GENERIC alpha


>Description:
	On the pkg_create(1) man page, the `-D' option (which defines 
	@display the packing list) says that the file specified will be 
	displayed to the user at installation time, using more(1). 

	Specifying a `-D' flag to pkg_create(1), and then using pkg_add(1)
	to install the package has the file displayed with out any
	paging.

>How-To-Repeat:
	Specify a file to be displayed that is larger than a single
	screen.  Watch it scroll away.
>Fix:
--- perform.c.orig	Mon Jul  5 21:58:26 1999
+++ perform.c	Mon Jul  5 22:03:49 1999
@@ -548,17 +548,27 @@
     }
 
     if ((p = find_plist(&Plist, PLIST_DISPLAY)) != NULL) {
-	FILE *fp;
+	struct stat sbuf;
+	char *Pager;
 	char buf[BUFSIZ];
 
+	/*
+	 * get the users PAGER environment variable, to use for
+	 * displaying the display file
+	 */
+	Pager = getenv("PAGER");
+	if (Pager == NULL) 
+	    Pager = "/usr/bin/more";
+
+	/* 
+	 * check to make sure the file exists, and if it does,
+	 * fire up PAGER to display it..  Since the rest of the pkg* 
+	 * code is littered with system(3c), we'll add one more here.
+	 */
 	snprintf(buf, sizeof buf, "%s/%s", LogDir, p->name);
-	fp = fopen(buf, "r");
-	if (fp) {
-	    putc('\n', stdout);
-	    while (fgets(buf, sizeof(buf), fp))
-		fputs(buf, stdout);
-	    putc('\n', stdout);
-	    (void) fclose(fp);
+	if (!stat(buf,&sbuf)) {
+	    snprintf(buf, sizeof buf, "%s %s/%s", Pager, LogDir, p->name);
+	    system(buf);
 	} else
 	    warnx("cannot open %s as display file", buf);
     }
>Audit-Trail:
>Unformatted: