until eof and returns. all the old garbage about printing headers and
sourcing .mailrc have been removed.
Added routine load() to read the user's .mailrc and /usr/lib/Mail.rc
SCCS-vsn: usr.bin/mail/lex.c 2.6
* Lexical processing of commands.
*/
* Lexical processing of commands.
*/
-static char *SccsId = "@(#)lex.c 2.5 %G%";
+static char *SccsId = "@(#)lex.c 2.6 %G%";
setmsize(msgCount);
fclose(ibuf);
relsesigs();
setmsize(msgCount);
fclose(ibuf);
relsesigs();
- int eofloop, shudprompt, firstsw, stop();
+ int eofloop, shudprompt, stop();
register int n;
char linebuf[LINESIZE];
int hangup(), contin();
sigset(SIGCONT, SIG_DFL);
register int n;
char linebuf[LINESIZE];
int hangup(), contin();
sigset(SIGCONT, SIG_DFL);
+ if (rcvmode && !sourcing) {
if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
sigset(SIGINT, stop);
if (sigset(SIGHUP, SIG_IGN) != SIG_IGN)
sigset(SIGHUP, hangup);
}
if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
sigset(SIGINT, stop);
if (sigset(SIGHUP, SIG_IGN) != SIG_IGN)
sigset(SIGHUP, hangup);
}
- input = stdin;
- shudprompt = 1;
- if (!intty)
- shudprompt = 0;
- firstsw = 1;
+ shudprompt = intty && !sourcing;
- if (firstsw > 0) {
- firstsw = 0;
- source1(mailrc);
- if (!nosrc)
- source1(MASTER);
- }
-
- /*
- * How's this for obscure: after we
- * finish sourcing for the first time,
- * go off and print the headers!
- */
-
- if (shudann && !sourcing) {
- shudann = 0;
- if (rcvmode)
- announce(edit);
- }
/*
* Print the prompt, if needed. Clear out
/*
* Print the prompt, if needed. Clear out
return;
eofloop = 0;
top:
return;
eofloop = 0;
top:
- if (shudprompt && !sourcing) {
sigset(SIGCONT, contin);
printf(prompt);
}
sigset(SIGCONT, contin);
printf(prompt);
}
if (readline(input, &linebuf[n]) <= 0) {
if (n != 0)
break;
if (readline(input, &linebuf[n]) <= 0) {
if (n != 0)
break;
if (sourcing) {
unstack();
goto more;
if (sourcing) {
unstack();
goto more;
- if (!edit)
- return;
- edstop();
return;
}
if ((n = strlen(linebuf)) == 0)
return;
}
if ((n = strlen(linebuf)) == 0)
return(0);
com = lex(word);
if (com == NONE) {
return(0);
com = lex(word);
if (com == NONE) {
+ printf("Unknown command: \"%s\"\n", word);
+ if (loading)
+ return(1);
if (sourcing)
unstack();
return(0);
if (sourcing)
unstack();
return(0);
*/
if (com->c_func == edstop && sourcing) {
*/
if (com->c_func == edstop && sourcing) {
+ if (loading)
+ return(1);
if (!rcvmode && (com->c_argtype & M) == 0) {
printf("May not execute \"%s\" while sending\n",
com->c_name);
if (!rcvmode && (com->c_argtype & M) == 0) {
printf("May not execute \"%s\" while sending\n",
com->c_name);
+ if (loading)
+ return(1);
if (sourcing)
unstack();
return(0);
if (sourcing)
unstack();
return(0);
if (sourcing && com->c_argtype & I) {
printf("May not execute \"%s\" while sourcing\n",
com->c_name);
if (sourcing && com->c_argtype & I) {
printf("May not execute \"%s\" while sourcing\n",
com->c_name);
+ if (loading)
+ return(1);
unstack();
return(0);
}
if (readonly && com->c_argtype & W) {
printf("May not execute \"%s\" -- message file is read only\n",
com->c_name);
unstack();
return(0);
}
if (readonly && com->c_argtype & W) {
printf("May not execute \"%s\" -- message file is read only\n",
com->c_name);
+ if (loading)
+ return(1);
if (sourcing)
unstack();
return(0);
if (sourcing)
unstack();
return(0);
* A message list defaulting to nearest forward
* legal message.
*/
* A message list defaulting to nearest forward
* legal message.
*/
+ if (msgvec == 0) {
+ printf("Illegal use of \"message list\"\n");
+ return(-1);
+ }
if ((c = getmsglist(cp, msgvec, com->c_msgflag)) < 0)
break;
if (c == 0) {
if ((c = getmsglist(cp, msgvec, com->c_msgflag)) < 0)
break;
if (c == 0) {
* A message list with no defaults, but no error
* if none exist.
*/
* A message list with no defaults, but no error
* if none exist.
*/
+ if (msgvec == 0) {
+ printf("Illegal use of \"message list\"\n");
+ return(-1);
+ }
if (getmsglist(cp, msgvec, com->c_msgflag) < 0)
break;
e = (*com->c_func)(msgvec);
if (getmsglist(cp, msgvec, com->c_msgflag) < 0)
break;
e = (*com->c_func)(msgvec);
+ if (e && loading)
+ return(1);
if (e && sourcing)
unstack();
if (com->c_func == edstop)
if (e && sourcing)
unstack();
if (com->c_func == edstop)
printf("Version %s\n", version);
return(0);
}
printf("Version %s\n", version);
return(0);
}
+
+/*
+ * Load a file of user definitions.
+ */
+load(name)
+ char *name;
+{
+ register FILE *in, *oldin;
+
+ if ((in = fopen(name, "r")) == NULL)
+ return;
+ oldin = input;
+ input = in;
+ loading = 1;
+ sourcing = 1;
+ commands();
+ loading = 0;
+ sourcing = 0;
+ input = oldin;
+ fclose(in);
+}