diff options
author | mikeh <mikeh@FreeBSD.org> | 2004-02-29 20:44:44 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2004-02-29 20:44:44 +0000 |
commit | 9d29f488fff50b2f5e4eb49f972fb3d0e3522029 (patch) | |
tree | 504aca9a1fd911180e61a965ba10728d59f52cbd /usr.bin/mail/lex.c | |
parent | 1631601f6d0b62bdd426c167f3a29cb48a797bbf (diff) | |
download | FreeBSD-src-9d29f488fff50b2f5e4eb49f972fb3d0e3522029.zip FreeBSD-src-9d29f488fff50b2f5e4eb49f972fb3d0e3522029.tar.gz |
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
Diffstat (limited to 'usr.bin/mail/lex.c')
-rw-r--r-- | usr.bin/mail/lex.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index 518c25b..973eee5 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); } /* |