aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/mail/lex.c
diff options
context:
space:
mode:
authorMike Heffner <mikeh@FreeBSD.org>2004-02-29 20:44:44 +0000
committerMike Heffner <mikeh@FreeBSD.org>2004-02-29 20:44:44 +0000
commitc92dfc231b25d5a31c652408ccabca73d7ebc506 (patch)
tree504aca9a1fd911180e61a965ba10728d59f52cbd /usr.bin/mail/lex.c
parent16c36bbe5db52e7c26fc7506c13439107f046d7a (diff)
downloadsrc-c92dfc231b25d5a31c652408ccabca73d7ebc506.tar.gz
src-c92dfc231b25d5a31c652408ccabca73d7ebc506.zip
Add the -e (mail presence test), -H (header summary mode), and -F
(message save as first recipient) options for standards conformance. Submitted by: Wartan Hachaturow <wart@tepkom.ru> (with some changes) PR: standards/61934
Notes
Notes: svn path=/head/; revision=126415
Diffstat (limited to 'usr.bin/mail/lex.c')
-rw-r--r--usr.bin/mail/lex.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index 518c25b6a3e4..973eee57fd00 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -60,13 +60,17 @@ extern const char *version;
* If the first character of name is %, we are considered to be
* editing the file, otherwise we are reading our mail which has
* signficance for mbox and so forth.
+ *
+ * If the -e option is being passed to mail, this function has a
+ * tri-state return code: -1 on error, 0 on no mail, 1 if there is
+ * mail.
*/
int
setfile(name)
char *name;
{
FILE *ibuf;
- int i, fd;
+ int checkmode, i, fd;
struct stat stb;
char isedit = *name != '%' || getuserid(myname) != getuid();
char *who = name[1] ? name + 1 : myname;
@@ -147,12 +151,17 @@ setfile(name)
(void)Fclose(ibuf);
relsesigs();
sawcom = 0;
- if (!edit && msgCount == 0) {
+ checkmode = value("checkmode") != NULL;
+
+ if ((checkmode || !edit) && msgCount == 0) {
nomail:
- fprintf(stderr, "No mail for %s\n", who);
- return (-1);
+ if (!checkmode) {
+ fprintf(stderr, "No mail for %s\n", who);
+ return (-1);
+ } else
+ return (0);
}
- return (0);
+ return (checkmode ? 1 : 0);
}
/*