diff options
Diffstat (limited to 'usr.bin/from/from.c')
-rw-r--r-- | usr.bin/from/from.c | 9 |
1 files changed, 7 insertions, 2 deletions
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 <ctype.h> #include <pwd.h> #include <stdio.h> +#include <string.h> #include <paths.h> 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); } |