after the initial edit.
.PP
When started, the editor is started on the draft (unless the
-.B \-edit
+.B \-editor
switch with an empty string argument is given,
in which case the initial edit is suppressed). Then,
.B whatnow
.BR whatnow 's
actions in complex ways.
.PP
+If the initial edit fails, no new draft is created, but any
+existing re-used draft is preserved.
+Failures of later edits are ignored and another prompt is printed.
+.PP
The
.B \-prompt
.I string
.SH CONTEXT
None
-
-.SH BUGS
-If the initial edit fails,
-.B whatnow
-deletes your draft (by renaming
-it with a leading comma); failure of a later edit preserves the draft.
/* start editing the draft, unless editor is the empty string */
if (*ed) {
if (editfile(&ed, NULL, drft, use, NULL, msgnam, NULL) <0) {
+ if (!use) {
+ unlink(drft);
+ }
+ advise(NULL, "Try again.");
done(1);
}
}
/* Call an editor on the draft file */
if (*++argp)
ed = *argp++;
- if (editfile(&ed, argp, drft, NOUSE, NULL,
- msgnam, NULL) == NOTOK)
- done(1);
+ editfile(&ed, argp, drft, NOUSE, NULL, msgnam, NULL);
break;
case LISTSW:
vec[vecp] = NULL;
execvp(*ed, vec);
- fprintf(stderr, "unable to exec ");
+ fprintf(stderr, "%s: unable to exec ", invo_name);
perror(*ed);
_exit(-1);
default:
if ((status = pidwait(pid, NOTOK))) {
- if (((status & 0xff00) != 0xff00) &&
- (!edsave || (status & 0x00ff))) {
- if (!use && (status & 0xff00) && (rename(file, cp = m_backup(file)) != NOTOK)) {
- advise(NULL, "problems with edit--draft left in %s", cp);
- } else {
- advise(NULL, "problems with edit--%s preserved", file);
- }
+ if ((status & 0xff00) == 0xff00) {
+ /* cmd not found or pidwait() failed */
+ status = -1;
+ break;
}
- status = -2; /* maybe "edsave ? -2 : -1"? */
+ if (status & 0x00ff) {
+ /* terminated by signal */
+ advise(NULL, "%s terminated by signal %d",
+ *ed, status & 0x7f);
+ } else {
+ /* failure exit */
+ advise(NULL, "%s exited with return code %d",
+ *ed, (status & 0xff00) >> 8);
+ }
+ status = -1;
break;
}
edsave = getcpy(*ed);
*ed = NULL;
- if (altmsg)
+ if (altmsg) {
unlink(linkpath);
+ }
return status;
}
vec[vecp] = NULL;
execvp("send", vec);
- fprintf(stderr, "unable to exec ");
+ fprintf(stderr, "%s: unable to exec ", invo_name);
perror("send");
_exit(-1);
case 0:
execvp(*vec, vec);
- fprintf(stderr, "unable to exec ");
+ fprintf(stderr, "%s: unable to exec ", invo_name);
perror(*vec);
_exit(-1);