summaryrefslogtreecommitdiffstats
path: root/usr.bin/from
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1996-01-28 23:43:37 +0000
committerwosch <wosch@FreeBSD.org>1996-01-28 23:43:37 +0000
commit1f24c85f7b49f79c25deea434e495f945f144a60 (patch)
tree93e637be90ddcdc235c2597b95d8549f5b70e596 /usr.bin/from
parent2e58df0ad2a23a1c3f55f3c49fbb33797847a8b6 (diff)
downloadFreeBSD-src-1f24c85f7b49f79c25deea434e495f945f144a60.zip
FreeBSD-src-1f24c85f7b49f79c25deea434e495f945f144a60.tar.gz
Read from standard input if file name "-" is given.
Diffstat (limited to 'usr.bin/from')
-rw-r--r--usr.bin/from/from.13
-rw-r--r--usr.bin/from/from.c9
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 <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);
}
OpenPOWER on IntegriCloud