Read from standard input if file name "-" is given.

This commit is contained in:
Wolfram Schneider 1996-01-28 23:43:37 +00:00
parent 89d1440458
commit 98d04b7c68
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13678
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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);
}