X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fwhatnow.c;h=7217096afe7a095598d5a5b6cf6ac5f738083e36;hp=08e3be84738f005fb22716e0e41aaf22f035b150;hb=32b2354dbaf4bf934936eb5b102a4a3d2fdd209a;hpb=75fca31a5b9d5c1a99c74ab14c94438d8852fba9 diff --git a/uip/whatnow.c b/uip/whatnow.c index 08e3be8..7217096 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -48,7 +48,7 @@ static struct swit whatnowswitches[] = { #define PRMPTSW 1 { "prompt string", 4 }, #define VERSIONSW 2 - { "version", 0 }, + { "Version", 0 }, #define HELPSW 3 { "help", 0 }, { NULL, 0 } @@ -197,6 +197,10 @@ main(int argc, char **argv) /* 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); } } @@ -223,9 +227,7 @@ main(int argc, char **argv) /* 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: @@ -654,21 +656,27 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, 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; } @@ -696,8 +704,9 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, edsave = getcpy(*ed); *ed = NULL; - if (altmsg) + if (altmsg) { unlink(linkpath); + } return status; } @@ -760,7 +769,7 @@ sendfile(char **arg, char *file) vec[vecp] = NULL; execvp("send", vec); - fprintf(stderr, "unable to exec "); + fprintf(stderr, "%s: unable to exec ", invo_name); perror("send"); _exit(-1); @@ -803,7 +812,7 @@ refile(char **arg, char *file) case 0: execvp(*vec, vec); - fprintf(stderr, "unable to exec "); + fprintf(stderr, "%s: unable to exec ", invo_name); perror(*vec); _exit(-1);