diff options
author | June McEnroe <june@causal.agency> | 2021-10-02 20:01:46 +0000 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2022-01-21 22:07:48 -0500 |
commit | 5e47599cbca6a93ab39cefb469666c40e150bd94 (patch) | |
tree | 2c711be8dabff0d535dce686d1cb186662f25157 /src | |
parent | dash: Warn twice about stopped jobs (diff) | |
download | dash-5e47599cbca6a93ab39cefb469666c40e150bd94.tar.gz dash-5e47599cbca6a93ab39cefb469666c40e150bd94.zip |
dash: Check sizes of mailboxes, not times
This fixes "you have mail" showing right after checking and deleting mail, resulting in a modified but empty mailbox. Also somehow fixes "you have mail" always showing 3(!) times.
Diffstat (limited to '')
-rw-r--r-- | src/mail.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mail.c b/src/mail.c index 8eacb2d..e6baaa1 100644 --- a/src/mail.c +++ b/src/mail.c @@ -52,8 +52,8 @@ #define MAXMBOXES 10 -/* times of mailboxes */ -static time_t mailtime[MAXMBOXES]; +/* sizes of mailboxes */ +static off_t mailsize[MAXMBOXES]; /* Set if MAIL or MAILPATH is changed. */ static int changed; @@ -70,13 +70,13 @@ chkmail(void) const char *mpath; char *p; char *q; - time_t *mtp; + off_t *msp; struct stackmark smark; struct stat64 statb; setstackmark(&smark); mpath = mpathset() ? mpathval() : mailval(); - for (mtp = mailtime; mtp < mailtime + MAXMBOXES; mtp++) { + for (msp = mailsize; msp < mailsize + MAXMBOXES; msp++) { int len; len = padvance_magic(&mpath, nullstr, 2); @@ -92,16 +92,16 @@ chkmail(void) #endif q[-1] = '\0'; /* delete trailing '/' */ if (stat64(p, &statb) < 0) { - *mtp = 0; + *msp = 0; continue; } - if (!changed && statb.st_mtime != *mtp) { + if (!changed && statb.st_size > *msp) { outfmt( &errout, snlfmt, pathopt ? pathopt : "you have mail" ); } - *mtp = statb.st_mtime; + *msp = statb.st_size; } changed = 0; popstackmark(&smark); |