From 1f24c85f7b49f79c25deea434e495f945f144a60 Mon Sep 17 00:00:00 2001 From: wosch Date: Sun, 28 Jan 1996 23:43:37 +0000 Subject: Read from standard input if file name "-" is given. --- usr.bin/from/from.1 | 3 +++ usr.bin/from/from.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/usr.bin/from/from.1 b/usr.bin/from/from.1 index f935b89..a09dbff 100644 --- a/usr.bin/from/from.1 +++ b/usr.bin/from/from.1 @@ -57,6 +57,9 @@ If the option is used, the .Ar user argument should not be used. +Read from standard input if file name +.Ar - +is given. .It Fl s Ar sender Only mail from addresses containing the diff --git a/usr.bin/from/from.c b/usr.bin/from/from.c index 324bceb..f9f301d 100644 --- a/usr.bin/from/from.c +++ b/usr.bin/from/from.c @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)from.c 8.1 (Berkeley) 6/6/93"; #include #include #include +#include #include main(argc, argv) @@ -63,7 +64,7 @@ main(argc, argv) #endif file = sender = NULL; - while ((ch = getopt(argc, argv, "f:s:")) != EOF) + while ((ch = getopt(argc, argv, "f:s:?")) != EOF) switch((char)ch) { case 'f': file = optarg; @@ -93,7 +94,11 @@ main(argc, argv) (void)sprintf(buf, "%s/%s", _PATH_MAILDIR, file); file = buf; } - if (!freopen(file, "r", stdin)) { + + /* read from stdin */ + if (strcmp(file, "-") == 0) { + } + else if (!freopen(file, "r", stdin)) { fprintf(stderr, "from: can't read %s.\n", file); exit(1); } -- cgit v1.1