summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mail/aux.c10
-rw-r--r--usr.bin/mail/cmd1.c107
-rw-r--r--usr.bin/mail/cmd3.c42
-rw-r--r--usr.bin/mail/cmdtab.c12
-rw-r--r--usr.bin/mail/collect.c10
-rw-r--r--usr.bin/mail/def.h41
-rw-r--r--usr.bin/mail/extern.h14
-rw-r--r--usr.bin/mail/fio.c33
-rw-r--r--usr.bin/mail/lex.c57
-rw-r--r--usr.bin/mail/list.c10
-rw-r--r--usr.bin/mail/names.c12
-rw-r--r--usr.bin/mail/pathnames.h20
-rw-r--r--usr.bin/mail/popen.c115
-rw-r--r--usr.bin/mail/quit.c6
-rw-r--r--usr.bin/mail/send.c62
-rw-r--r--usr.bin/mail/vars.c23
-rw-r--r--usr.bin/mail/version.c6
17 files changed, 400 insertions, 180 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c
index f418991eebc..1af0b2ee680 100644
--- a/usr.bin/mail/aux.c
+++ b/usr.bin/mail/aux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aux.c,v 1.15 2000/06/30 16:00:18 millert Exp $ */
+/* $OpenBSD: aux.c,v 1.16 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: aux.c,v 1.15 2000/06/30 16:00:18 millert Exp $";
+static char rcsid[] = "$OpenBSD: aux.c,v 1.16 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -115,7 +115,7 @@ isdir(name)
if (stat(name, &sbuf) < 0)
return(0);
- return (S_ISDIR(sbuf.st_mode));
+ return(S_ISDIR(sbuf.st_mode));
}
/*
@@ -352,7 +352,11 @@ alter(name)
return;
(void) gettimeofday(&tv[0], (struct timezone *)0);
tv[0].tv_sec++;
+#ifdef TIMESPEC_TO_TIMEVAL
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
+#else
+ tv[1].tv_sec = sb.st_mtime;
+#endif
(void)utimes(name, tv);
}
diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c
index b53a92c40cc..66e28520934 100644
--- a/usr.bin/mail/cmd1.c
+++ b/usr.bin/mail/cmd1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd1.c,v 1.16 2000/06/30 16:00:18 millert Exp $ */
+/* $OpenBSD: cmd1.c,v 1.17 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: cmd1.c,v 1.9 1997/07/09 05:29:48 mikel Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: cmd1.c,v 1.16 2000/06/30 16:00:18 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmd1.c,v 1.17 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -181,6 +181,9 @@ printhead(mesg)
struct headline hl;
int subjlen;
char *name;
+ char *to, *from;
+ struct name *np;
+ char **ap;
mp = &message[mesg-1];
(void)readline(setinput(mp), headline, LINESIZE);
@@ -202,16 +205,32 @@ printhead(mesg)
if (mp->m_flag & MBOX)
dispc = 'M';
parse(headline, &hl, pbuf);
- (void)snprintf(wcount, sizeof(wcount), "%3d/%-5d", mp->m_lines,
+ (void)snprintf(wcount, sizeof(wcount), "%4d/%-5d", mp->m_lines,
mp->m_size);
- subjlen = screenwidth - 50 - strlen(wcount);
- name = value("show-rcpt") != NULL ?
- skin(hfield("to", mp)) : nameof(mp, 0);
- if (subjline == NULL || subjlen < 0) /* pretty pathetic */
- printf("%c%c%3d %-20.20s %16.16s %s\n",
- curind, dispc, mesg, name, hl.l_date, wcount);
+ subjlen = screenwidth - 44 - strlen(wcount);
+ from = nameof(mp, 0);
+ to = skin(hfield("to", mp));
+ np = extract(from, GTO);
+ np = delname(np, myname);
+ if (altnames)
+ for (ap = altnames; *ap; ap++)
+ np = delname(np, *ap);
+ if (np)
+ /* not from me */
+ name = value("show-rcpt") != NULL && to ? to : from;
else
- printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n",
+ /* from me - show TO */
+ name = value("showto") != NULL && to ? to : from;
+ if (subjline == NULL || subjlen < 0) { /* pretty pathetic */
+ subjline="";
+ subjlen=0;
+ }
+ if (name == to)
+ printf("%c%c%3d TO %-14.14s %16.16s %s %.*s\n",
+ curind, dispc, mesg, name, hl.l_date, wcount,
+ subjlen, subjline);
+ else
+ printf("%c%c%3d %-17.17s %16.16s %s %.*s\n",
curind, dispc, mesg, name, hl.l_date, wcount,
subjlen, subjline);
}
@@ -254,6 +273,19 @@ pcmdlist(v)
}
/*
+ * Pipe message to command
+ */
+int
+pipeit(ml, sl)
+ void *ml, *sl;
+{
+ int *msgvec = ml;
+ char *cmd = sl;
+
+ return(type1(msgvec, cmd, 0, 0));
+}
+
+/*
* Paginate messages, honor ignored fields.
*/
int
@@ -261,7 +293,7 @@ more(v)
void *v;
{
int *msgvec = v;
- return(type1(msgvec, 1, 1));
+ return(type1(msgvec, NULL, 1, 1));
}
/*
@@ -273,7 +305,7 @@ More(v)
{
int *msgvec = v;
- return(type1(msgvec, 0, 1));
+ return(type1(msgvec, NULL, 0, 1));
}
/*
@@ -285,7 +317,7 @@ type(v)
{
int *msgvec = v;
- return(type1(msgvec, 1, 0));
+ return(type1(msgvec, NULL, 1, 0));
}
/*
@@ -297,7 +329,7 @@ Type(v)
{
int *msgvec = v;
- return(type1(msgvec, 0, 0));
+ return(type1(msgvec, NULL, 0, 0));
}
/*
@@ -305,14 +337,16 @@ Type(v)
*/
sigjmp_buf pipestop;
int
-type1(msgvec, doign, page)
+type1(msgvec, cmd, doign, page)
int *msgvec;
+ char *cmd;
int doign, page;
{
int nlines, *ip;
struct message *mp;
char *cp;
FILE *obuf;
+
#if __GNUC__
/* Avoid siglongjmp clobbering */
(void)&cp;
@@ -322,18 +356,27 @@ type1(msgvec, doign, page)
obuf = stdout;
if (sigsetjmp(pipestop, 1))
goto close_pipe;
- if (value("interactive") != NULL &&
- (page || (cp = value("crt")) != NULL)) {
+
+ /*
+ * start a pipe if needed.
+ */
+ if (cmd) {
+ obuf = Popen(cmd, "w");
+ if (obuf == NULL) {
+ warn("%s", cp);
+ obuf = stdout;
+ } else {
+ (void)signal(SIGPIPE, brokpipe);
+ }
+ } else if (value("interactive") != NULL &&
+ (page || (cp = value("crt")) != NULL)) {
nlines = 0;
if (!page) {
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++)
nlines += message[*ip - 1].m_lines;
}
if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) {
- cp = value("PAGER");
- if (cp == NULL || *cp == '\0')
- cp = _PATH_MORE;
- obuf = Popen(cp, "w");
+ obuf = Popen(value("PAGER"), "w");
if (obuf == NULL) {
warn("%s", cp);
obuf = stdout;
@@ -341,14 +384,19 @@ type1(msgvec, doign, page)
(void)signal(SIGPIPE, brokpipe);
}
}
+
+ /*
+ * send messages to the output.
+ */
for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) {
mp = &message[*ip - 1];
touch(mp);
dot = mp;
- if (value("quiet") == NULL)
+ if (cmd == NULL && value("quiet") == NULL)
fprintf(obuf, "Message %d:\n", *ip);
(void)sendmessage(mp, obuf, doign ? ignore : 0, NULL);
}
+
close_pipe:
if (obuf != stdout) {
/*
@@ -460,16 +508,18 @@ int
folders(v)
void *v;
{
+ char *files = (char *)v;
char dirname[PATHSIZE];
- char *cmd;
+ char cmd[BUFSIZ];
if (getfold(dirname, sizeof(dirname)) < 0) {
- puts("No value set for \"folder\"");
- return(1);
+ strcpy(dirname, "$HOME");
}
- if ((cmd = value("LISTER")) == NULL)
- cmd = "ls";
- (void)run_command(cmd, 0, -1, -1, dirname, NULL, NULL);
+
+ snprintf(cmd, sizeof(cmd), "cd %s; %s %s", dirname, value("LISTER"),
+ files && *files ? files : "");
+
+ (void)run_command(value("SHELL"), 0, -1, -1, "-c", cmd, NULL);
return(0);
}
@@ -490,7 +540,6 @@ inc(v)
} else if (nmsg > 0) {
mdot = newfileinfo(msgCount - nmsg);
dot = &message[mdot - 1];
- clearnew();
} else {
puts("\"inc\" command failed...");
}
diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c
index 22576a11366..07a3bec4040 100644
--- a/usr.bin/mail/cmd3.c
+++ b/usr.bin/mail/cmd3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd3.c,v 1.13 2000/08/02 04:10:48 millert Exp $ */
+/* $OpenBSD: cmd3.c,v 1.14 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: cmd3.c,v 1.13 2000/08/02 04:10:48 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmd3.c,v 1.14 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -69,8 +69,7 @@ shell(v)
cmd[sizeof(cmd) - 1] = '\0';
if (bangexp(cmd, sizeof(cmd)) < 0)
return(1);
- if ((shell = value("SHELL")) == NULL)
- shell = _PATH_CSHELL;
+ shell = value("SHELL");
(void)run_command(shell, 0, -1, -1, "-c", cmd, NULL);
(void)signal(SIGINT, sigint);
puts("!");
@@ -88,8 +87,7 @@ dosh(v)
sig_t sigint = signal(SIGINT, SIG_IGN);
char *shell;
- if ((shell = value("SHELL")) == NULL)
- shell = _PATH_CSHELL;
+ shell = value("SHELL");
(void)run_command(shell, 0, -1, -1, NULL, NULL, NULL);
(void)signal(SIGINT, sigint);
putchar('\n');
@@ -154,21 +152,12 @@ overf:
/*
* Print out a nice help message from some file or another.
*/
-
int
help(v)
void *v;
{
- int c;
- FILE *f;
- if ((f = Fopen(_PATH_HELP, "r")) == NULL) {
- warn(_PATH_HELP);
- return(1);
- }
- while ((c = getc(f)) != EOF)
- putchar(c);
- (void)Fclose(f);
+ (void)run_command(value("PAGER"), 0, -1, -1, _PATH_HELP, NULL);
return(0);
}
@@ -295,6 +284,25 @@ reedit(subj)
}
/*
+ * Mark new the named messages, so that they will be left in the system
+ * mailbox as unread.
+ */
+int
+marknew(v)
+ void *v;
+{
+ int *msgvec = v;
+ int *ip;
+
+ for (ip = msgvec; *ip != NULL; ip++) {
+ dot = &message[*ip-1];
+ dot->m_flag &= ~(MBOX|MREAD|MTOUCH);
+ dot->m_flag |= MNEW|MSTATUS;
+ }
+ return(0);
+}
+
+/*
* Preserve the named messages, so that they will be sent
* back to the system mailbox.
*/
@@ -327,7 +335,7 @@ int
unread(v)
void *v;
{
- int *msgvec = v;
+ int *msgvec = v;
int *ip;
for (ip = msgvec; *ip != NULL; ip++) {
diff --git a/usr.bin/mail/cmdtab.c b/usr.bin/mail/cmdtab.c
index f6e28960ec4..efc4020ab47 100644
--- a/usr.bin/mail/cmdtab.c
+++ b/usr.bin/mail/cmdtab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmdtab.c,v 1.4 1997/07/13 21:21:10 millert Exp $ */
+/* $OpenBSD: cmdtab.c,v 1.5 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: cmdtab.c,v 1.7 1996/12/28 07:10:59 tls Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.4 1997/07/13 21:21:10 millert Exp $";
+static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.5 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -52,6 +52,9 @@ static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.4 1997/07/13 21:21:10 millert Exp
*/
const struct cmd cmdtab[] = {
+ /* msgmask msgflag */
+ /* command function argtype result & mask */
+ /* ------- -------- ------- ------- -------- */
{ "next", next, NDMLIST, 0, MMNDEL },
{ "alias", group, M|RAWLIST, 0, 1000 },
{ "print", type, MSGLIST, 0, MMNDEL },
@@ -69,6 +72,8 @@ const struct cmd cmdtab[] = {
{ "unset", unset, M|RAWLIST, 1, 1000 },
{ "mail", sendmail, R|M|I|STRLIST, 0, 0 },
{ "mbox", mboxit, W|MSGLIST, 0, 0 },
+ { "pipe", pipeit, MSGLIST|STRLIST,0, MMNDEL },
+ { "|", pipeit, MSGLIST|STRLIST,0, MMNDEL },
{ "more", more, MSGLIST, 0, MMNDEL },
{ "page", more, MSGLIST, 0, MMNDEL },
{ "More", More, MSGLIST, 0, MMNDEL },
@@ -88,7 +93,7 @@ const struct cmd cmdtab[] = {
{ "from", from, MSGLIST, 0, MMNORM },
{ "file", file, T|M|RAWLIST, 0, 1 },
{ "folder", file, T|M|RAWLIST, 0, 1 },
- { "folders", folders, T|M|NOLIST, 0, 0 },
+ { "folders", folders, T|M|STRLIST, 0, 0 },
{ "?", help, M|NOLIST, 0, 0 },
{ "z", scroll, M|STRLIST, 0, 0 },
{ "headers", headers, MSGLIST, 0, MMNDEL },
@@ -121,5 +126,6 @@ const struct cmd cmdtab[] = {
{ "#", null, M|NOLIST, 0, 0 },
{ "clobber", clobber, M|RAWLIST, 0, 1 },
{ "inc", inc, T|NOLIST, 0, 0 },
+ { "new", marknew, MSGLIST, 0, MMNDEL },
{ 0, 0, 0, 0, 0 }
};
diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index 4e39ded1d9e..95af3e3bbb8 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: collect.c,v 1.19 2000/06/30 16:00:17 millert Exp $ */
+/* $OpenBSD: collect.c,v 1.20 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
#else
-static char rcsid[] = "$OpenBSD: collect.c,v 1.19 2000/06/30 16:00:17 millert Exp $";
+static char rcsid[] = "$OpenBSD: collect.c,v 1.20 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -192,8 +192,7 @@ cont:
value("interactive") != NULL && !lastlong &&
(value("dot") != NULL || value("ignoreeof") != NULL))
break;
- if (linebuf[0] != escape || value("interactive") == NULL ||
- lastlong) {
+ if (linebuf[0] != escape || lastlong) {
if (putline(collf, linebuf, !longline) < 0)
goto err;
continue;
@@ -524,8 +523,7 @@ mespipe(fp, cmd)
* stdin = current message.
* stdout = new message.
*/
- if ((shell = value("SHELL")) == NULL)
- shell = _PATH_CSHELL;
+ shell = value("SHELL");
if (run_command(shell,
0, fileno(fp), fileno(nf), "-c", cmd, NULL) < 0) {
(void)Fclose(nf);
diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h
index 234dfc7b4de..533a2932998 100644
--- a/usr.bin/mail/def.h
+++ b/usr.bin/mail/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.6 1997/07/14 00:24:26 millert Exp $ */
+/* $OpenBSD: def.h,v 1.7 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: def.h,v 1.9 1996/12/28 07:11:00 tls Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*
* @(#)def.h 8.4 (Berkeley) 4/20/95
- * $OpenBSD: def.h,v 1.6 1997/07/14 00:24:26 millert Exp $
+ * $OpenBSD: def.h,v 1.7 2001/01/16 05:36:08 millert Exp $
*/
/*
@@ -42,6 +42,9 @@
* Author: Kurt Shoens (UCB) March 25, 1978
*/
+#ifndef MAIL_DEF_H
+#define MAIL_DEF_H
+
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -107,7 +110,13 @@ struct message {
*/
struct cmd {
char *c_name; /* Name of command */
- int (*c_func) __P((void *));/* Implementor of the command */
+ union {
+ int (*c_func0)();
+ int (*c_func1) __P((void *));
+ int (*c_func2) __P((void *, void *));
+ } cfunc; /* Implementor of the command */
+#define c_func cfunc.c_func1
+#define c_func2 cfunc.c_func2
short c_argtype; /* Type of arglist (see below) */
short c_msgflag; /* Required flags of messages */
short c_msgmask; /* Relevant flags of messages */
@@ -122,19 +131,19 @@ struct cmd {
* Argument types.
*/
-#define MSGLIST 0 /* Message list type */
-#define STRLIST 1 /* A pure string */
-#define RAWLIST 2 /* Shell string list */
-#define NOLIST 3 /* Just plain 0 */
-#define NDMLIST 4 /* Message list, no defaults */
+#define MSGLIST 0x0001 /* Message list type */
+#define STRLIST 0x0002 /* A pure string */
+#define RAWLIST 0x0004 /* Shell string list */
+#define NOLIST 0x0008 /* Just plain 0 */
+#define NDMLIST 0x0010 /* Message list, no defaults */
-#define P 040 /* Autoprint dot after command */
-#define I 0100 /* Interactive command bit */
-#define M 0200 /* Legal from send mode bit */
-#define W 0400 /* Illegal when read only bit */
-#define F 01000 /* Is a conditional command */
-#define T 02000 /* Is a transparent command */
-#define R 04000 /* Cannot be called from collect */
+#define P 0x0020 /* Autoprint dot after command */
+#define I 0x0040 /* Interactive command bit */
+#define M 0x0080 /* Legal from send mode bit */
+#define W 0x0100 /* Illegal when read only bit */
+#define F 0x0200 /* Is a conditional command */
+#define T 0x0400 /* Is a transparent command */
+#define R 0x0800 /* Cannot be called from collect */
/*
* Oft-used mask values
@@ -277,3 +286,5 @@ struct ignoretab {
(void)fflush(stream); \
(void)ftruncate(fileno(stream), (off_t)ftell(stream)); \
}
+
+#endif /* MAIL_DEF_H */
diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h
index 5fa9f3c03bf..d3698d96308 100644
--- a/usr.bin/mail/extern.h
+++ b/usr.bin/mail/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.15 2000/08/23 21:24:08 mickey Exp $ */
+/* $OpenBSD: extern.h,v 1.16 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: extern.h,v 1.7 1997/07/09 05:22:00 mikel Exp $ */
/*-
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/20/95
- * $OpenBSD: extern.h,v 1.15 2000/08/23 21:24:08 mickey Exp $
+ * $OpenBSD: extern.h,v 1.16 2001/01/16 05:36:08 millert Exp $
*/
struct name;
@@ -180,6 +180,7 @@ void mail1 __P((struct header *, int));
void makemessage __P((FILE *, int));
void mark __P((int));
int markall __P((char [], int));
+int marknew __P((void *));
int matchsender __P((char *, int));
int matchsubj __P((char *, int));
int mboxit __P((void *));
@@ -196,6 +197,7 @@ struct headline;
void parse __P((char [], struct headline *, char []));
int pcmdlist __P((void *));
int pdot __P((void *));
+int pipeit __P((void *, void *));
void prepare_child __P((sigset_t *, int, int));
int preserve __P((void *));
void prettyprint __P((struct name *));
@@ -215,7 +217,7 @@ int respond __P((void *));
int retfield __P((void *));
int rexit __P((void *));
int rm __P((char *));
-int run_command __P((char *, sigset_t *, int, int, char *, char *, char *));
+int run_command __P((char *cmd, sigset_t *nset, int infd, int outfd, ...));
int save __P((void *));
int save1 __P((char [], int, char *, struct ignoretab *));
void savedeadletter __P((FILE *));
@@ -242,7 +244,8 @@ int spool_lock __P((void));
int spool_unlock __P((void));
void spreserve __P((void));
void sreset __P((void));
-int start_command __P((char *, sigset_t *, int, int, char *, char *, char *));
+int start_command __P((char *cmd, sigset_t *nset, int infd, int outfd, ...));
+int start_commandv __P((char *, sigset_t *, int, int, _BSD_VA_LIST_));
void statusput __P((struct message *, FILE *, char *));
void stop __P((int));
int stouch __P((void *));
@@ -253,7 +256,7 @@ void touch __P((struct message *));
void ttyint __P((int));
void ttystop __P((int));
int type __P((void *));
-int type1 __P((int *, int, int));
+int type1 __P((int *, char *, int, int));
int undeletecmd __P((void *));
void unmark __P((int));
char **unpack __P((struct name *, struct name *));
@@ -269,3 +272,4 @@ int writeback __P((FILE *));
extern char *__progname;
extern char *tmpdir;
+extern const struct cmd *com; /* command we are running */
diff --git a/usr.bin/mail/fio.c b/usr.bin/mail/fio.c
index 2a64f6d3802..3589a49c3f9 100644
--- a/usr.bin/mail/fio.c
+++ b/usr.bin/mail/fio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fio.c,v 1.17 2000/08/02 04:10:48 millert Exp $ */
+/* $OpenBSD: fio.c,v 1.18 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: fio.c,v 1.17 2000/08/02 04:10:48 millert Exp $";
+static char rcsid[] = "$OpenBSD: fio.c,v 1.18 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -58,6 +58,22 @@ static char rcsid[] = "$OpenBSD: fio.c,v 1.17 2000/08/02 04:10:48 millert Exp $"
*/
/*
+ * Wrapper for read() to catch EINTR.
+ */
+ssize_t
+myread(fd, buf, len)
+ int fd;
+ char *buf;
+ int len;
+{
+ ssize_t nread;
+
+ while ((nread = read(fd, buf, len)) == -1 && errno == EINTR)
+ ;
+ return(nread);
+}
+
+/*
* Set up the input pointers while copying the mail file into /tmp.
*/
void
@@ -251,7 +267,7 @@ makemessage(f, omsgCount)
size -= (omsgCount + 1) * sizeof(struct message);
fflush(f);
(void)lseek(fileno(f), (off_t)sizeof(*message), 0);
- if (read(fileno(f), (void *) &message[omsgCount], size) != size)
+ if (myread(fileno(f), (void *) &message[omsgCount], size) != size)
errx(1, "Message temporary file corrupted");
message[msgCount].m_size = 0;
message[msgCount].m_lines = 0;
@@ -400,8 +416,7 @@ expand(name)
return(name);
}
(void)snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name);
- if ((shell = value("SHELL")) == NULL)
- shell = _PATH_CSHELL;
+ shell = value("SHELL");
pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NULL);
if (pid < 0) {
(void)close(pivec[0]);
@@ -409,17 +424,17 @@ expand(name)
return(NULL);
}
(void)close(pivec[1]);
- l = read(pivec[0], xname, PATHSIZE);
+ l = myread(pivec[0], xname, PATHSIZE);
+ if (l < 0)
+ warn("read"); /* report error before errno changes */
(void)close(pivec[0]);
if (wait_child(pid) < 0 && WIFSIGNALED(wait_status) &&
WTERMSIG(wait_status) != SIGPIPE) {
fprintf(stderr, "\"%s\": Expansion failed.\n", name);
return(NULL);
}
- if (l < 0) {
- warn("read");
+ if (l < 0)
return(NULL);
- }
if (l == 0) {
fprintf(stderr, "\"%s\": No match.\n", name);
return(NULL);
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index b5e2c37278d..148f618d8b4 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.21 2000/07/06 06:24:21 deraadt Exp $ */
+/* $OpenBSD: lex.c,v 1.22 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
#else
-static char rcsid[] = "$OpenBSD: lex.c,v 1.21 2000/07/06 06:24:21 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: lex.c,v 1.22 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -55,6 +55,8 @@ static char rcsid[] = "$OpenBSD: lex.c,v 1.21 2000/07/06 06:24:21 deraadt Exp $"
char *prompt = "& ";
+const struct cmd *com; /* command we are running */
+
/*
* Set up editing on the given file name.
* If the first character of name is %, we are considered to be
@@ -297,11 +299,12 @@ execute(linebuf, contxt)
{
char word[LINESIZE];
char *arglist[MAXARGC];
- const struct cmd *com = NULL;
char *cp, *cp2;
int c, muvec[2];
int e = 1;
+ com = NULL;
+
/*
* Strip the white space away from the beginning
* of the command, then scan out a word, which
@@ -378,6 +381,53 @@ execute(linebuf, contxt)
goto out;
}
switch (com->c_argtype & ~(F|P|I|M|T|W|R)) {
+ case MSGLIST|STRLIST:
+ /*
+ * A message list defaulting to nearest forward
+ * legal message.
+ */
+ if (msgvec == 0) {
+ puts("Illegal use of \"message list\"");
+ break;
+ }
+ /*
+ * remove leading blanks.
+ */
+ while (isspace(*cp))
+ cp++;
+
+ if (isdigit(*cp) || *cp == ':') {
+ if ((c = getmsglist(cp, msgvec, com->c_msgflag)) < 0)
+ break;
+ /* position to next space - past the message list */
+ while (!isspace(*cp))
+ cp++;
+ /* position to next non-space */
+ while (isspace(*cp))
+ cp++;
+ } else {
+ c = 0; /* no message list */
+ }
+
+ if (c == 0) {
+ *msgvec = first(com->c_msgflag,
+ com->c_msgmask);
+ msgvec[1] = NULL;
+ }
+ if (*msgvec == NULL) {
+ puts("No applicable messages");
+ break;
+ }
+ /*
+ * Just the straight string, with
+ * leading blanks removed.
+ */
+ while (isspace(*cp))
+ cp++;
+
+ e = (*com->c_func2)(msgvec, cp);
+ break;
+
case MSGLIST:
/*
* A message list defaulting to nearest forward
@@ -614,7 +664,6 @@ announce()
int vec[2], mdot;
mdot = newfileinfo(0);
- clearnew();
vec[0] = mdot;
vec[1] = 0;
dot = &message[mdot - 1];
diff --git a/usr.bin/mail/list.c b/usr.bin/mail/list.c
index 565bc686923..dc9ddb7d725 100644
--- a/usr.bin/mail/list.c
+++ b/usr.bin/mail/list.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: list.c,v 1.9 1997/11/14 00:23:49 millert Exp $ */
+/* $OpenBSD: list.c,v 1.10 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: list.c,v 1.7 1997/07/09 05:23:36 mikel Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)list.c 8.4 (Berkeley) 5/1/95";
#else
-static char rcsid[] = "$OpenBSD: list.c,v 1.9 1997/11/14 00:23:49 millert Exp $";
+static char rcsid[] = "$OpenBSD: list.c,v 1.10 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -216,9 +216,11 @@ number:
return(-1);
}
colmod |= colresult;
+ } else {
+ if ((com->c_argtype & ~(F|P|I|M|T|W|R))
+ != (MSGLIST|STRLIST))
+ *np++ = savestr(lexstring);
}
- else
- *np++ = savestr(lexstring);
break;
case TDOLLAR:
diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c
index 7a0a0c4c7d1..4f9601785a2 100644
--- a/usr.bin/mail/names.c
+++ b/usr.bin/mail/names.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: names.c,v 1.12 2000/08/23 21:24:08 mickey Exp $ */
+/* $OpenBSD: names.c,v 1.13 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: names.c,v 1.12 2000/08/23 21:24:08 mickey Exp $";
+static char rcsid[] = "$OpenBSD: names.c,v 1.13 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -303,8 +303,7 @@ outof(names, fo, hp)
* share the same lseek location and trample
* on one another.
*/
- if ((shell = value("SHELL")) == NULL)
- shell = _PATH_CSHELL;
+ shell = value("SHELL");
sigemptyset(&nset);
sigaddset(&nset, SIGHUP);
sigaddset(&nset, SIGINT);
@@ -676,7 +675,10 @@ delname(np, name)
struct name *p;
for (p = np; p != NIL; p = p->n_flink)
- if (strcasecmp(p->n_name, name) == 0) {
+ if ((strcasecmp(p->n_name, name) == 0) ||
+ (value("allnet") &&
+ strncasecmp(p->n_name, name, strlen(name)) == 0 &&
+ *(p->n_name+strlen(name)) == '@')) {
if (p->n_blink == NIL) {
if (p->n_flink != NIL)
p->n_flink->n_blink = NIL;
diff --git a/usr.bin/mail/pathnames.h b/usr.bin/mail/pathnames.h
index c85150b6d94..3712c43a8ad 100644
--- a/usr.bin/mail/pathnames.h
+++ b/usr.bin/mail/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.4 1998/08/15 23:17:22 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.5 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.4 1996/06/08 19:48:34 christos Exp $ */
/*
@@ -39,9 +39,15 @@
#include <paths.h>
-#define _PATH_EX "/usr/bin/ex"
-#define _PATH_HELP "/usr/share/misc/mail.help"
-#define _PATH_TILDE "/usr/share/misc/mail.tildehelp"
-#define _PATH_MASTER_RC "/etc/mail.rc"
-#define _PATH_MORE "/usr/bin/more"
-#define _PATH_LOCKSPOOL "/usr/libexec/lockspool"
+/* executables */
+#define _PATH_EX "/usr/bin/ex"
+#define _PATH_MORE "/usr/bin/more"
+#define _PATH_LS "/usr/bin/ls"
+#define _PATH_LOCKSPOOL "/usr/libexec/lockspool"
+
+/* directories & files */
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_HELP "/usr/share/misc/mail.help"
+#define _PATH_TILDE "/usr/share/misc/mail.tildehelp"
+#define _PATH_MASTER_RC "/etc/mail.rc"
+#define _PATH_LOCTMP "/tmp/local.XXXXXXXXXX"
diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c
index e93e6c36564..786b28441ed 100644
--- a/usr.bin/mail/popen.c
+++ b/usr.bin/mail/popen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popen.c,v 1.24 2000/06/30 16:00:18 millert Exp $ */
+/* $OpenBSD: popen.c,v 1.25 2001/01/16 05:36:08 millert Exp $ */
/* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: popen.c,v 1.24 2000/06/30 16:00:18 millert Exp $";
+static char rcsid[] = "$OpenBSD: popen.c,v 1.25 2001/01/16 05:36:08 millert Exp $";
#endif
#endif /* not lint */
@@ -46,6 +46,11 @@ static char rcsid[] = "$OpenBSD: popen.c,v 1.24 2000/06/30 16:00:18 millert Exp
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
#include "extern.h"
#define READ 0
@@ -124,15 +129,15 @@ Popen(cmd, mode)
(void)fcntl(p[WRITE], F_SETFD, 1);
if (*mode == 'r') {
myside = p[READ];
- fd0 = -1;
- hisside = fd1 = p[WRITE];
+ hisside = fd0 = fd1 = p[WRITE];
} else {
myside = p[WRITE];
hisside = fd0 = p[READ];
fd1 = -1;
}
sigemptyset(&nset);
- if ((pid = start_command(cmd, &nset, fd0, fd1, NULL, NULL, NULL)) < 0) {
+ if ((pid = start_command(value("SHELL"), &nset, fd0, fd1,
+ "-c", cmd, NULL)) < 0) {
(void)close(p[READ]);
(void)close(p[WRITE]);
return(NULL);
@@ -224,32 +229,16 @@ file_pid(fp)
* "nset" contains the signals to ignore in the new process.
* SIGINT is enabled unless it's in "nset".
*/
-/*VARARGS4*/
int
-run_command(cmd, nset, infd, outfd, a0, a1, a2)
+start_commandv(cmd, nset, infd, outfd, args)
char *cmd;
sigset_t *nset;
int infd, outfd;
- char *a0, *a1, *a2;
+ va_list args;
{
int pid;
- if ((pid = start_command(cmd, nset, infd, outfd, a0, a1, a2)) < 0)
- return(-1);
- return(wait_command(pid));
-}
-
-/*VARARGS4*/
-int
-start_command(cmd, nset, infd, outfd, a0, a1, a2)
- char *cmd;
- sigset_t *nset;
- int infd, outfd;
- char *a0, *a1, *a2;
-{
- int pid;
-
- if ((pid = vfork()) < 0) {
+ if ((pid = fork()) < 0) {
warn("fork");
return(-1);
}
@@ -257,10 +246,9 @@ start_command(cmd, nset, infd, outfd, a0, a1, a2)
char *argv[100];
int i = getrawlist(cmd, argv, sizeof(argv)/ sizeof(*argv));
- if ((argv[i++] = a0) != NULL &&
- (argv[i++] = a1) != NULL &&
- (argv[i++] = a2) != NULL)
- argv[i] = NULL;
+ while ((argv[i++] = va_arg(args, char *)))
+ ;
+ argv[i] = NULL;
prepare_child(nset, infd, outfd);
execvp(argv[0], argv);
warn("%s", argv[0]);
@@ -269,6 +257,58 @@ start_command(cmd, nset, infd, outfd, a0, a1, a2)
return(pid);
}
+int
+#ifdef __STDC__
+run_command(char *cmd, sigset_t *nset, int infd, int outfd, ...)
+#else
+run_command(cmd, nset, infd, outfd, va_alist)
+ char *cmd;
+ sigset_t *nset;
+ int infd;
+ int outfd;
+ va_dcl
+#endif
+{
+ int pid;
+ va_list args;
+
+#ifdef __STDC__
+ va_start(args, outfd);
+#else
+ va_start(args);
+#endif
+ pid = start_commandv(cmd, nset, infd, outfd, args);
+ va_end(args);
+ if (pid < 0)
+ return(-1);
+ return(wait_command(pid));
+}
+
+int
+#ifdef __STDC__
+start_command(char *cmd, sigset_t *nset, int infd, int outfd, ...)
+#else
+start_command(cmd, nset, infd, outfd, va_alist)
+ char *cmd;
+ sigset_t *nset;
+ int infd;
+ int outfd;
+ va_dcl
+#endif
+{
+ va_list args;
+ int r;
+
+#ifdef __STDC__
+ va_start(args, outfd);
+#else
+ va_start(args);
+#endif
+ r = start_commandv(cmd, nset, infd, outfd, args);
+ va_end(args);
+ return(r);
+}
+
void
prepare_child(nset, infd, outfd)
sigset_t *nset;
@@ -281,8 +321,13 @@ prepare_child(nset, infd, outfd)
* All file descriptors other than 0, 1, and 2 are supposed to be
* close-on-exec.
*/
- if (infd >= 0)
+ if (infd >= 0) {
dup2(infd, 0);
+ } else {
+ /* we don't want the child stealing my stdin input */
+ close(0);
+ open(_PATH_DEVNULL, O_RDONLY, 0);
+ }
if (outfd >= 0)
dup2(outfd, 1);
if (nset == NULL)
@@ -451,18 +496,18 @@ handle_spool_locks(action)
(void)Pclose(lockfp);
lockfp = NULL;
} else if (action == 1) {
- char *cmd = _PATH_LOCKSPOOL;
+ char cmd[128];
/* XXX - lockspool requires root for user arg, we do not */
- if (uflag && asprintf(&cmd, "%s %s", _PATH_LOCKSPOOL,
- myname) == -1)
+ if (snprintf(cmd, sizeof(cmd), "%s %s", _PATH_LOCKSPOOL, uflag ? myname : "") < 0)
errx(1, "Out of memory");
/* Create the lock */
lockfp = Popen(cmd, "r");
- if (uflag)
- free(cmd);
- if (lockfp == NULL || getc(lockfp) != '1') {
+ if (lockfp == NULL)
+ return(0);
+ if (getc(lockfp) != '1') {
+ Pclose(lockfp);
lockfp = NULL;
return(0);
}
diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c
index 3119f691731..1fe4b088a27 100644
--- a/usr.bin/mail/quit.c
+++ b/usr.bin/mail/quit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quit.c,v 1.13 2000/06/30 16:00:18 millert Exp $ */
+/* $OpenBSD: quit.c,v 1.14 2001/01/16 05:36:09 millert Exp $ */
/* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: quit.c,v 1.13 2000/06/30 16:00:18 millert Exp $";
+static char rcsid[] = "$OpenBSD: quit.c,v 1.14 2001/01/16 05:36:09 millert Exp $";
#endif
#endif /* not lint */
@@ -108,7 +108,7 @@ quit()
* a message.
*/
- fbuf = Fopen(mailname, "r");
+ fbuf = Fopen(mailname, "r+");
if (fbuf == NULL)
goto newmail;
if (flock(fileno(fbuf), LOCK_EX) == -1) {
diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c
index 26d048669e5..0c0685427bb 100644
--- a/usr.bin/mail/send.c
+++ b/usr.bin/mail/send.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: send.c,v 1.12 2000/08/23 21:24:08 mickey Exp $ */
+/* $OpenBSD: send.c,v 1.13 2001/01/16 05:36:09 millert Exp $ */
/* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: send.c,v 1.12 2000/08/23 21:24:08 mickey Exp $";
+static char rcsid[] = "$OpenBSD: send.c,v 1.13 2001/01/16 05:36:09 millert Exp $";
#endif
#endif /* not lint */
@@ -179,12 +179,13 @@ sendmessage(mp, obuf, doign, prefix)
* Strip trailing whitespace from prefix
* if line is blank.
*/
- if (prefix != NULL)
+ if (prefix != NULL) {
if (length > 1)
fputs(prefix, obuf);
else
(void)fwrite(prefix, sizeof(*prefix),
prefixlen, obuf);
+ }
(void)fwrite(line, sizeof(*line), length, obuf);
if (ferror(obuf))
return(-1);
@@ -195,13 +196,13 @@ sendmessage(mp, obuf, doign, prefix)
*/
if (doign == ignoreall)
count--; /* skip final blank line */
- if (prefix != NULL)
- while (count > 0) {
- if (fgets(line, sizeof(line), ibuf) == NULL) {
- c = 0;
- break;
- }
- count -= c = strlen(line);
+ while (count > 0) {
+ if (fgets(line, sizeof(line), ibuf) == NULL) {
+ c = 0;
+ break;
+ }
+ count -= c = strlen(line);
+ if (prefix != NULL) {
/*
* Strip trailing whitespace from prefix
* if line is blank.
@@ -211,19 +212,19 @@ sendmessage(mp, obuf, doign, prefix)
else
(void)fwrite(prefix, sizeof(*prefix),
prefixlen, obuf);
- (void)fwrite(line, sizeof(*line), c, obuf);
- if (ferror(obuf))
- return(-1);
- }
- else
- while (count > 0) {
- c = count < LINESIZE ? count : LINESIZE;
- if ((c = fread(line, sizeof(*line), c, ibuf)) <= 0)
- break;
- count -= c;
- if (fwrite(line, sizeof(*line), c, obuf) != c)
- return(-1);
}
+ /*
+ * We can't read the record file (or inbox for recipient)
+ * properly with 'From ' lines in the message body (from
+ * forwarded messages or sentences starting with "From "),
+ * so we will prepend those lines with a '>'.
+ */
+ if (strncmp(line, "From ", 5) == 0)
+ (void)fwrite(">", 1, 1, obuf); /* '>' before 'From ' */
+ (void)fwrite(line, sizeof(*line), c, obuf);
+ if (ferror(obuf))
+ return(-1);
+ }
if (doign == ignoreall && c > 0 && line[c - 1] != '\n')
/* no final blank line */
if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF)
@@ -315,11 +316,12 @@ mail1(hp, printheaders)
*/
if ((mtf = collect(hp, printheaders)) == NULL)
return;
- if (fsize(mtf) == 0)
+ if (fsize(mtf) == 0) {
if (hp->h_subject == NULL)
puts("No message, no subject; hope that's ok");
else
puts("Null message body; hope that's ok");
+ }
/*
* Now, take the user names from the combined
* to and cc lists and do all the alias
@@ -546,7 +548,6 @@ savemail(name, fi)
{
FILE *fo;
char buf[BUFSIZ];
- int i;
time_t now;
if ((fo = Fopen(name, "a")) == NULL) {
@@ -555,8 +556,17 @@ savemail(name, fi)
}
(void)time(&now);
fprintf(fo, "From %s %s", myname, ctime(&now));
- while ((i = fread(buf, 1, sizeof(buf), fi)) > 0)
- (void)fwrite(buf, 1, i, fo);
+ while (fgets(buf, sizeof(buf), fi) == buf) {
+ /*
+ * We can't read the record file (or inbox for recipient)
+ * in the message body (from forwarded messages or sentences
+ * starting with "From "), so we will prepend those lines with
+ * a '>'.
+ */
+ if (strncmp(buf, "From ", 5) == 0)
+ (void)fwrite(">", 1, 1, fo); /* '>' before 'From ' */
+ (void)fwrite(buf, 1, strlen(buf), fo);
+ }
(void)putc('\n', fo);
(void)fflush(fo);
if (ferror(fo))
diff --git a/usr.bin/mail/vars.c b/usr.bin/mail/vars.c
index 30bfcf8ad42..2a1eed995d4 100644
--- a/usr.bin/mail/vars.c
+++ b/usr.bin/mail/vars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vars.c,v 1.5 1997/11/14 00:24:01 millert Exp $ */
+/* $OpenBSD: vars.c,v 1.6 2001/01/16 05:36:09 millert Exp $ */
/* $NetBSD: vars.c,v 1.4 1996/06/08 19:48:45 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: vars.c,v 1.5 1997/11/14 00:24:01 millert Exp $";
+static char rcsid[] = "$OpenBSD: vars.c,v 1.6 2001/01/16 05:36:09 millert Exp $";
#endif
#endif /* not lint */
@@ -118,10 +118,21 @@ value(name)
char name[];
{
struct var *vp;
-
- if ((vp = lookup(name)) == NOVAR)
- return(getenv(name));
- return(vp->v_value);
+ char *env;
+
+ if ((vp = lookup(name)) != NOVAR)
+ return(vp->v_value);
+ else if ((env = getenv(name)))
+ return(env);
+ /* not set, see if we can provide a default */
+ else if (strcmp(name, "SHELL") == 0)
+ return(_PATH_CSHELL);
+ else if (strcmp(name, "LISTER") == 0)
+ return(_PATH_LS);
+ else if (strcmp(name, "PAGER") == 0)
+ return(_PATH_MORE);
+ else
+ return(NULL);
}
/*
diff --git a/usr.bin/mail/version.c b/usr.bin/mail/version.c
index 3591c8a9872..02482700450 100644
--- a/usr.bin/mail/version.c
+++ b/usr.bin/mail/version.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: version.c,v 1.3 1997/06/18 23:52:28 deraadt Exp $ */
+/* $OpenBSD: version.c,v 1.4 2001/01/16 05:36:09 millert Exp $ */
/* $NetBSD: version.c,v 1.4 1996/06/08 19:48:46 christos Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: version.c,v 1.3 1997/06/18 23:52:28 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: version.c,v 1.4 2001/01/16 05:36:09 millert Exp $";
#endif
#endif /* not lint */
@@ -46,4 +46,4 @@ static char rcsid[] = "$OpenBSD: version.c,v 1.3 1997/06/18 23:52:28 deraadt Exp
* Just keep track of the date/sid of this version of Mail.
* Load this file first to get a "total" Mail version.
*/
-char *version = "8.1.1 18/6/97";
+char *version = "8.1.2 01/15/2001";