Subject: bin/982: banner prints unnecessary prompt
To: None <gnats-admin@NetBSD.ORG>
From: Masanobu Saitoh <saitoh@spa.is.uec.ac.jp>
List: netbsd-bugs
Date: 04/20/1995 11:35:02
>Number:         982
>Category:       bin
>Synopsis:       banner prints unnecessary prompt
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 20 11:35:01 1995
>Originator:     Masanobu Saitoh
>Organization:
	     saitoh@spa.is.uec.ac.jp
>Release:        NetBSD-current 18 Apr 1995
>Environment:
System: NetBSD physio.spa.is.uec.ac.jp 1.0 NetBSD 1.0 (NBTY) #809: Wed Apr 19 05:25:39 JST 1995 saitoh@physio.spa.is.uec.ac.jp:/usr/sources/0124/src/sys/arch/x68k/compile/NBTY x68k

>Description:
	Even if banner's stdin isn't tty, it prompts "Message: ".

>How-To-Repeat:
	Try following command

		echo foo |banner |head
>Fix:
	Apply this patch.

--- banner.c.orig	Fri Apr 21 02:13:10 1995
+++ banner.c	Fri Apr 21 03:16:14 1995
@@ -49,7 +49,7 @@
 
 /*
  * banner - prints large signs
- * banner [-w#] [-d] [-t] message ...
+ * banner [-w[#]] [-d] [-t] [message ...]
  */
 
 #include <err.h>
@@ -1051,7 +1051,7 @@
 			break;
 		case '?':
 		default:
-			fprintf(stderr, "usage: banner [-w width]\n");
+			fprintf(stderr, "usage: banner [-w [width]] [message ...]\n");
 			exit(1);
 		}
 	argc -= optind;
@@ -1071,7 +1071,8 @@
 		}
 		nchars = strlen(message);
 	} else {
-		fprintf(stderr,"Message: ");
+		if (isatty(0))
+			fprintf(stderr,"Message: ");
 		(void)fgets(message, sizeof(message), stdin);
 		nchars = strlen(message);
 		message[nchars--] = '\0';	/* get rid of newline */

>Audit-Trail:
>Unformatted: