aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/from
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1996-10-06 01:54:22 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1996-10-06 01:54:22 +0000
commit338fc8eb62853c5e4ff1d06d333eea97927af9dd (patch)
tree50da2e885a33bcfc5895cbeeeb08dc04e2496cb3 /usr.bin/from
parent30fcdae27e86dc1282fafe7ed1529aeadccd6045 (diff)
downloadsrc-338fc8eb62853c5e4ff1d06d333eea97927af9dd.tar.gz
src-338fc8eb62853c5e4ff1d06d333eea97927af9dd.zip
Honor the MAIL environment variable, if set.
Submitted-by: Dan Cross <cross@math.psu.edu>
Notes
Notes: svn path=/head/; revision=18725
Diffstat (limited to 'usr.bin/from')
-rw-r--r--usr.bin/from/from.15
-rw-r--r--usr.bin/from/from.c22
2 files changed, 20 insertions, 7 deletions
diff --git a/usr.bin/from/from.1 b/usr.bin/from/from.1
index a09dbff6f1a4..780eba839a83 100644
--- a/usr.bin/from/from.1
+++ b/usr.bin/from/from.1
@@ -72,6 +72,11 @@ is given, the
.Ar user Ns 's
mailbox, is examined instead of the invoker's own mailbox.
(Privileges are required.)
+.Sh ENVIRONMENT
+.Bl -tag -width Fl
+.It Ev MAIL
+If set, the location of the invoker's mailbox. Otherwise, the default
+in /var/mail is used.
.Sh FILES
.Bl -tag -width /var/mail/* -compact
.It Pa /var/mail/*
diff --git a/usr.bin/from/from.c b/usr.bin/from/from.c
index f9f301d9435f..de6205731a94 100644
--- a/usr.bin/from/from.c
+++ b/usr.bin/from/from.c
@@ -42,9 +42,11 @@ static char sccsid[] = "@(#)from.c 8.1 (Berkeley) 6/6/93";
#endif /* not lint */
#include <sys/types.h>
+
#include <ctype.h>
#include <pwd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <paths.h>
@@ -83,16 +85,22 @@ main(argc, argv)
argv += optind;
if (!file) {
- if (!(file = *argv)) {
- if (!(pwd = getpwuid(getuid()))) {
- fprintf(stderr,
+ if (*argv) {
+ (void)sprintf(buf, "%s/%s", _PATH_MAILDIR, *argv);
+ file = buf;
+ } else {
+ if (!(file = getenv("MAIL"))) {
+ if (!(pwd = getpwuid(getuid()))) {
+ (void)fprintf(stderr,
"from: no password file entry for you.\n");
- exit(1);
+ exit(1);
+ }
+ file = pwd->pw_name;
+ (void)sprintf(buf,
+ "%s/%s", _PATH_MAILDIR, file);
+ file = buf;
}
- file = pwd->pw_name;
}
- (void)sprintf(buf, "%s/%s", _PATH_MAILDIR, file);
- file = buf;
}
/* read from stdin */