Date: Fri, 2 Apr 1999 13:11:38 -0500 (EST) From: James howard <howardjp@byzantine.student.umd.edu> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/10921: I wished from(1) would count the number of messages. Message-ID: <199904021811.NAA07533@byzantine.student.umd.edu>
index | next in thread | raw e-mail
>Number: 10921
>Category: bin
>Synopsis: I wished from(1) would count the number of messages.
>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 Apr 2 10:10:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: James howard
>Release: FreeBSD 4.0-CURRENT i386
>Organization:
University of Maryland
>Environment:
FreeBSD byzantine.student.umd.edu 4.0-CURRENT FreeBSD 4.0-CURRENT #2: Thu Apr 1 00:29:18 EST 1999 howardjp@byzantine.student.umd.edu:/usr/src/sys/compile/BYZANTINE i386
>Description:
I typed ``message'' the other day at a command prompt and when nothing
happened I realized elm was not installed. So anyway, rather than
installing elm, I patched from(1) so that when given the option -c
it will behave just like message(1L).
>How-To-Repeat:
>Fix:
Apply the following patch to /usr/src/usr.bin/from and it will
patch from.c and update from.1 with the needed changes.
diff -c -r /usr/src/usr.bin/from/from.1 from/from.1
*** /usr/src/usr.bin/from/from.1 Sat Oct 5 21:54:21 1996
--- from/from.1 Fri Apr 2 11:48:40 1999
***************
*** 39,44 ****
--- 39,45 ----
.Nd print names of those who have sent mail
.Sh SYNOPSIS
.Nm from
+ .Op Fl c
.Op Fl s Ar sender
.Op Fl f Ar file
.Op Ar user
***************
*** 49,54 ****
--- 50,57 ----
.Pp
Options:
.Bl -tag -width Fl
+ .It Fl c
+ Only provide a count of messages.
.It Fl f Ar file
The supplied file
is examined instead of the invoker's mailbox.
diff -c -r /usr/src/usr.bin/from/from.c from/from.c
*** /usr/src/usr.bin/from/from.c Tue Jul 8 06:59:50 1997
--- from/from.c Fri Apr 2 10:32:41 1999
***************
*** 66,72 ****
extern char *optarg;
extern int optind;
struct passwd *pwd;
! int ch, newline;
char *file, *sender, *p;
#if MAXPATHLEN > BUFSIZ
char buf[MAXPATHLEN];
--- 66,72 ----
extern char *optarg;
extern int optind;
struct passwd *pwd;
! int ch, count = -1, newline;
char *file, *sender, *p;
#if MAXPATHLEN > BUFSIZ
char buf[MAXPATHLEN];
***************
*** 75,82 ****
#endif
file = sender = NULL;
! while ((ch = getopt(argc, argv, "f:s:")) != -1)
switch((char)ch) {
case 'f':
file = optarg;
break;
--- 75,85 ----
#endif
file = sender = NULL;
! while ((ch = getopt(argc, argv, "cf:s:")) != -1)
switch((char)ch) {
+ case 'c':
+ count = 0;
+ break;
case 'f':
file = optarg;
break;
***************
*** 120,136 ****
continue;
}
if (newline && !strncmp(buf, "From ", 5) &&
! (!sender || match(buf + 5, sender)))
! printf("%s", buf);
newline = 0;
}
exit(0);
}
static void
usage()
{
! fprintf(stderr, "usage: from [-f file] [-s sender] [user]\n");
exit(1);
}
--- 123,153 ----
continue;
}
if (newline && !strncmp(buf, "From ", 5) &&
! (!sender || match(buf + 5, sender)))
! if (count != -1)
! count++;
! else
! printf("%s", buf);
newline = 0;
}
+ if (count != -1)
+ switch(count) {
+ case 0:
+ printf("There are no messages in your incoming mailbox.\n");
+ break;
+ case 1:
+ printf("There is 1 message in your incoming mailbox.\n");
+ break;
+ default:
+ printf("There are %i messages in your incoming mailbox.\n", count);
+ }
exit(0);
}
static void
usage()
{
! fprintf(stderr, "usage: from [-c] [-f file] [-s sender] [user]\n");
exit(1);
}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904021811.NAA07533>
