Skip to content

Commit

Permalink
Honor the MAIL environment variable, if set.
Browse files Browse the repository at this point in the history
Submitted-by: Dan Cross <[email protected]>
  • Loading branch information
jkh authored and jkh committed Oct 6, 1996
1 parent abca754 commit 588cbc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
5 changes: 5 additions & 0 deletions usr.bin/from/from.1
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
22 changes: 15 additions & 7 deletions usr.bin/from/from.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 588cbc5

Please sign in to comment.