/* $Header: ngstuff.c,v 4.3.1.2 85/05/10 14:31:52 lwall Exp $
* Revision 4.3.1.2 85/05/10 14:31:52 lwall
* Prevented "Junked" or "Marked unread" when no state change.
* Revision 4.3.1.1 85/05/10 11:36:45 lwall
* Revision 4.3 85/05/01 11:45:03 lwall
* Baseline for release with 4.3bsd.
bool interactive
= (buf
[1] == FINISHCMD
);
if (!finish_command(interactive
)) /* get remainder of command */
/* skip leading spaces */
interp(cmd_buf
, (sizeof cmd_buf
), s
);/* interpret any % escapes */
resetty(); /* make sure tty is friendly */
doshell(Nullch
,cmd_buf
); /* invoke the shell */
noecho(); /* and make terminal */
crmode(); /* unfriendly again */
printf(nocd
,whereiam
) FLUSH
;
mailcount
= 0; /* force recheck */
if (!finish_command(TRUE
)) /* get rest of command */
return -1; /* if rubbed out, try something else */
else if (buf
[1] == '&') {
for (s
=buf
+2; isspace(*s
); s
++);
mac_line(s
,tmpbuf
,(sizeof tmpbuf
));
bool docd
= (instr(buf
,"-d") != Nullch
);
if (chdir(whereami
)) { /* -d does chdirs */
printf(nocd
,whereami
) FLUSH
;
/* process range commands */
bool justone
= TRUE
; /* assume only one article */
if (!finish_command(TRUE
)) /* get rest of command */
fputs("\nNo articles\n",stdout
) FLUSH
;
for (s
=buf
; *s
&& (isdigit(*s
) || index(" ,-.$",*s
)); s
++)
safecpy(tmpbuf
,buf
,LBUFLEN
);
for (s
= tmpbuf
; c
= index(s
,','); s
= ++c
) {
if (min
<absfirst
) { /* make sure it is reasonable */
printf("(First article is %ld)\n",(long)absfirst
) FLUSH
;
if ((s
=index(s
,'-')) != Nullch
) {
printf("(Last article is %ld)\n",(long)lastart
) FLUSH
;
fputs("\nBad range\n",stdout
) FLUSH
;
for (art
=min
; art
<=max
; art
++) {
if (perform(cmdlst
,TRUE
)) {
printf("\n(Interrupted at article %ld)\n",(long)art
)
printf("\n(Intr at %ld)\n",(long)art
) FLUSH
;
for (; ch
= *cmdlst
; cmdlst
++) {
if (isspace(ch
) || ch
== ':')
fputs("\tJunked",stdout
);
fputs("\tMarked unread",stdout
);
fputs("\tWill return",stdout
);
printf("\t%s",fetchsubj(art
,FALSE
,FALSE
));
putchar('\n') FLUSH
; /* ghad! */
printf("\t%sancelled",(cancel_article() ? "Not c" : "C"));
cmdlst
= dointerp(tmpbuf
, (sizeof tmpbuf
), cmdlst
,":");
if (perform(tmpbuf
,FALSE
))
else if (index("!&sSwW|",ch
)) {
cmdlst
= cpytill(buf
,cmdlst
,':') - 1;
/* we now have the command in buf */
fputs("\tShell escaped",stdout
);
fputs("\tSwitched",stdout
);
printf("\t???%s\n",cmdlst
);