sh: Don't use padvance() for MAIL/MAILPATH
Using padvance() requires undoing its append of '/' and prevents adjusting its '%' logic to allow most directories with '%' in PATH. No functional change is intended.
This commit is contained in:
parent
ee150a3376
commit
7d6f6a3532
@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "exec.h" /* defines padvance() */
|
|
||||||
#include "mail.h"
|
#include "mail.h"
|
||||||
#include "var.h"
|
#include "var.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
@ -72,9 +71,9 @@ void
|
|||||||
chkmail(int silent)
|
chkmail(int silent)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *mpath;
|
char *mpath;
|
||||||
char *p;
|
char *p;
|
||||||
char *q;
|
char *msg;
|
||||||
struct stackmark smark;
|
struct stackmark smark;
|
||||||
struct stat statb;
|
struct stat statb;
|
||||||
|
|
||||||
@ -83,22 +82,25 @@ chkmail(int silent)
|
|||||||
if (nmboxes == 0)
|
if (nmboxes == 0)
|
||||||
return;
|
return;
|
||||||
setstackmark(&smark);
|
setstackmark(&smark);
|
||||||
mpath = mpathset()? mpathval() : mailval();
|
mpath = stsavestr(mpathset()? mpathval() : mailval());
|
||||||
for (i = 0 ; i < nmboxes ; i++) {
|
for (i = 0 ; i < nmboxes ; i++) {
|
||||||
p = padvance(&mpath, "");
|
p = mpath;
|
||||||
if (p == NULL)
|
|
||||||
break;
|
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
continue;
|
break;
|
||||||
for (q = p ; *q ; q++);
|
mpath = strchrnul(mpath, ':');
|
||||||
if (q[-1] != '/')
|
if (*mpath != '\0') {
|
||||||
abort();
|
*mpath++ = '\0';
|
||||||
q[-1] = '\0'; /* delete trailing '/' */
|
if (p == mpath - 1)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
msg = strchr(p, '%');
|
||||||
|
if (msg != NULL)
|
||||||
|
*msg++ = '\0';
|
||||||
#ifdef notdef /* this is what the System V shell claims to do (it lies) */
|
#ifdef notdef /* this is what the System V shell claims to do (it lies) */
|
||||||
if (stat(p, &statb) < 0)
|
if (stat(p, &statb) < 0)
|
||||||
statb.st_mtime = 0;
|
statb.st_mtime = 0;
|
||||||
if (statb.st_mtime > mailtime[i] && ! silent) {
|
if (statb.st_mtime > mailtime[i] && ! silent) {
|
||||||
out2str(pathopt? pathopt : "you have mail");
|
out2str(msg? msg : "you have mail");
|
||||||
out2c('\n');
|
out2c('\n');
|
||||||
}
|
}
|
||||||
mailtime[i] = statb.st_mtime;
|
mailtime[i] = statb.st_mtime;
|
||||||
@ -106,7 +108,7 @@ chkmail(int silent)
|
|||||||
if (stat(p, &statb) < 0)
|
if (stat(p, &statb) < 0)
|
||||||
statb.st_size = 0;
|
statb.st_size = 0;
|
||||||
if (statb.st_size > mailtime[i] && ! silent) {
|
if (statb.st_size > mailtime[i] && ! silent) {
|
||||||
out2str(pathopt? pathopt : "you have mail");
|
out2str(msg? msg : "you have mail");
|
||||||
out2c('\n');
|
out2c('\n');
|
||||||
}
|
}
|
||||||
mailtime[i] = statb.st_size;
|
mailtime[i] = statb.st_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user