From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 21 12:10:19 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E573B16A4CE for ; Fri, 21 Nov 2003 12:10:18 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4EDBF43FE3 for ; Fri, 21 Nov 2003 12:10:17 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id hALKAHFY008185 for ; Fri, 21 Nov 2003 12:10:17 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id hALKAHCf008184; Fri, 21 Nov 2003 12:10:17 -0800 (PST) (envelope-from gnats) Resent-Date: Fri, 21 Nov 2003 12:10:17 -0800 (PST) Resent-Message-Id: <200311212010.hALKAHCf008184@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ibrahim Abdullah Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AC29116A4D1 for ; Fri, 21 Nov 2003 12:01:47 -0800 (PST) Received: from smtp6.mindspring.com (smtp6.mindspring.com [207.69.200.110]) by mx1.FreeBSD.org (Postfix) with ESMTP id D087D43F75 for ; Fri, 21 Nov 2003 12:01:46 -0800 (PST) (envelope-from ibrahim@mind.daemon.sh) Received: from sdn-ap-024dcwashp0157.dialsprint.net ([63.191.176.157]) by smtp6.mindspring.com with esmtp (Exim 3.33 #1) id 1ANHTN-0001v5-00 for FreeBSD-gnats-submit@freebsd.org; Fri, 21 Nov 2003 15:01:45 -0500 Message-Id: <200311211502.24290.ibrahim@mind.daemon.sh> Date: Fri, 21 Nov 2003 15:02:24 -0500 From: Ibrahim Abdullah To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/59564: [PATCHES] Add option to from command to also show subjects X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2003 20:10:19 -0000 >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@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: