bin/59564: [PATCHES] Add option to from command to also show subjects

Ibrahim Abdullah ibrahim at mind.daemon.sh
Fri Nov 21 12:10:19 PST 2003


>Number:         59564
>Category:       bin
>Synopsis:       Added an option (-S) to from command to also display subject headers.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 21 12:10:14 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Ibrahim Abdullah
>Release:        FreeBSD 5.1-RELEASE-p10 i386
>Organization:
none
>Environment:
System: FreeBSD mind.daemon.sh 5.1-RELEASE-p10 FreeBSD 5.1-RELEASE-p10 #0: Sat Nov 15 22:17:30
EST 2003 root at mind.daemon.sh:/usr/obj/usr/src/sys/NEW i386


>Description:
	I added an option to /usr/src/usr.bin/from/from.c to enable it to display subject headers.
>How-To-Repeat:
	Not a problem report. Add patches below to /usr/src/usr.bin/from/from.c and /usr/src/usr.bin/from/from.1
>Fix:

Patch for from.c:

--- /usr/src/usr.bin/from/from.c	Wed Sep  4 19:29:00 2002
+++ from.c	Fri Nov 21 01:53:53 2003
@@ -63,7 +63,7 @@
 {
 	FILE *mbox;
 	struct passwd *pwd;
-	int ch, count, newline;
+	int ch, count, subject, newline;
 	const char *file;
 	char *sender, *p;
 #if MAXPATHLEN > BUFSIZ
@@ -74,8 +74,12 @@
 
 	file = sender = NULL;
 	count = -1;
-	while ((ch = getopt(argc, argv, "cf:s:")) != -1)
+	subject = 0;
+	while ((ch = getopt(argc, argv, "Scf:s:")) != -1)
 		switch (ch) {
+		case 'S':
+			subject = 1;
+			break;
 		case 'c':
 			count = 0;
 			break;
@@ -125,10 +129,17 @@
 		}
 		if (newline && !strncmp(buf, "From ", 5) &&
 		    (!sender || match(buf + 5, sender))) {
-			if (count != -1)
+			if (count != -1) {
 				count++;
-			else
+			} else {
 				printf("%s", buf);
+				while (subject && fgets(buf, sizeof(buf), mbox)) {
+					if (*buf == '\n')
+						break;
+					if (!strncmp(buf, "Subject: ", 9))
+						printf("    %s", buf);
+				}
+			}
 		}
 		newline = 0;
 	}
@@ -142,7 +153,7 @@
 static void
 usage(void)
 {
-	fprintf(stderr, "usage: from [-c] [-f file] [-s sender] [user]\n");
+	fprintf(stderr, "usage: from [-S] [-c] [-f file] [-s sender] [user]\n");
 	exit(1);
 }
 

Patch fo from.1

--- /usr/src/usr.bin/from/from.1	Mon Jul 15 02:15:38 2002
+++ from.1	Fri Nov 21 00:12:59 2003
@@ -40,6 +40,7 @@
 .Nd print names of those who have sent mail
 .Sh SYNOPSIS
 .Nm
+.Op Fl S
 .Op Fl c
 .Op Fl s Ar sender
 .Op Fl f Ar file
@@ -52,6 +53,8 @@
 .Pp
 The following options are available:
 .Bl -tag -width indent
+.It Fl S
+Also display subject headers.
 .It Fl c
 Just print a count of messages and exit.
 .It Fl f Ar file

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list