summaryrefslogtreecommitdiffstats
path: root/usr.bin/from
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-07-26 23:12:12 +0000
committergreen <green@FreeBSD.org>1999-07-26 23:12:12 +0000
commitf54e4029ae10032ebfc72c8c4ac1f8d954ebfe97 (patch)
tree2bea0a9ad4c01bcb3c798858f0cff096b836f494 /usr.bin/from
parent6eff605357b85284d28c7d3510e9d7370e3196a8 (diff)
downloadFreeBSD-src-f54e4029ae10032ebfc72c8c4ac1f8d954ebfe97.zip
FreeBSD-src-f54e4029ae10032ebfc72c8c4ac1f8d954ebfe97.tar.gz
*** empty log message ***
Diffstat (limited to 'usr.bin/from')
-rw-r--r--usr.bin/from/from.15
-rw-r--r--usr.bin/from/from.c25
2 files changed, 22 insertions, 8 deletions
diff --git a/usr.bin/from/from.1 b/usr.bin/from/from.1
index 683530b..4c5077b 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 c246ad4..bd0e580 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);
}
OpenPOWER on IntegriCloud