diff options
author | Brian Feldman <green@FreeBSD.org> | 1999-07-26 23:12:12 +0000 |
---|---|---|
committer | Brian Feldman <green@FreeBSD.org> | 1999-07-26 23:12:12 +0000 |
commit | 82753326e883f5c3771b6b324c0f9b7bead8e5fb (patch) | |
tree | 3518350eb58d4aefc0dc1a480ab8a3979a2fb7b4 /usr.bin/from | |
parent | 73fac075b24476924bc2eef76ef193fb079647ad (diff) | |
download | src-test2-82753326e883f5c3771b6b324c0f9b7bead8e5fb.tar.gz src-test2-82753326e883f5c3771b6b324c0f9b7bead8e5fb.zip |
Notes
Diffstat (limited to 'usr.bin/from')
-rw-r--r-- | usr.bin/from/from.1 | 5 | ||||
-rw-r--r-- | usr.bin/from/from.c | 25 |
2 files changed, 22 insertions, 8 deletions
diff --git a/usr.bin/from/from.1 b/usr.bin/from/from.1 index 683530bdeaaa..4c5077be657f 100644 --- a/usr.bin/from/from.1 +++ b/usr.bin/from/from.1 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)from.1 8.2 (Berkeley) 12/30/93 -.\" $Id$ +.\" $Id: from.1,v 1.4 1999/07/12 20:23:30 nik Exp $ .\" .Dd December 30, 1993 .Dt FROM 1 @@ -40,6 +40,7 @@ .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 @@ -50,6 +51,8 @@ out the mail header lines from the invoker's mailbox. .Pp Options: .Bl -tag -width Fl +.It Fl c +Just print a count of messages and exit. .It Fl f Ar file The supplied file is examined instead of the invoker's mailbox. diff --git a/usr.bin/from/from.c b/usr.bin/from/from.c index c246ad4e150a..bd0e5804e4cf 100644 --- a/usr.bin/from/from.c +++ b/usr.bin/from/from.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)from.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: from.c,v 1.5 1997/07/08 10:59:50 charnier Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -66,7 +66,7 @@ main(argc, argv) extern char *optarg; extern int optind; struct passwd *pwd; - int ch, newline; + int ch, count, newline; char *file, *sender, *p; #if MAXPATHLEN > BUFSIZ char buf[MAXPATHLEN]; @@ -75,8 +75,12 @@ main(argc, argv) #endif file = sender = NULL; - while ((ch = getopt(argc, argv, "f:s:")) != -1) - switch((char)ch) { + count = -1; + while ((ch = getopt(argc, argv, "cf:s:")) != -1) + switch (ch) { + case 'c': + count = 0; + break; case 'f': file = optarg; break; @@ -120,17 +124,24 @@ main(argc, argv) continue; } if (newline && !strncmp(buf, "From ", 5) && - (!sender || match(buf + 5, sender))) - printf("%s", buf); + (!sender || match(buf + 5, sender))) { + if (count != -1) + count++; + else + printf("%s", buf); + } newline = 0; } + if (count != -1) + printf("There %s %d message%s in your incoming mailbox.\n", + count == 1 ? "is" : "are", count, count == 1 ? "" : "s"); exit(0); } static void usage() { - fprintf(stderr, "usage: from [-f file] [-s sender] [user]\n"); + fprintf(stderr, "usage: from [-c] [-f file] [-s sender] [user]\n"); exit(1); } |