+ }
+
+ /* start editing the draft, unless -noedit was given */
+ if (!nedit && editfile(&ed, NULL, drft, use, NULL, msgnam, NULL, 1)
+ < 0)
+ done(1);
+
+ snprintf(prompt, sizeof(prompt), myprompt, invo_name);
+ for (;;) {
+ if (!(argp = getans(prompt, aleqs))) {
+ unlink(altmsglink);
+ done(1);
+ }
+ switch (smatch(*argp, aleqs)) {
+ case DISPSW:
+ /*
+ ** display the message being replied to,
+ ** or distributed
+ */
+ if (msgnam)
+ showfile(++argp, msgnam);
+ else
+ advise(NULL, "no alternate message to display");
+ break;
+
+ case BUILDMIMESW:
+ /* Translate MIME composition file */
+ buildfile(++argp, drft);
+ break;
+
+ case EDITSW:
+ /* Call an editor on the draft file */
+ if (*++argp)
+ ed = *argp++;
+ if (editfile(&ed, argp, drft, NOUSE, NULL,
+ msgnam, NULL, 1) == NOTOK)
+ done(1);
+ break;
+
+ case LISTSW:
+ /* display the draft file */
+ showfile(++argp, drft);
+ break;
+
+ case QUITSW:
+ /* Quit, and possibly delete the draft */
+ if (*++argp && (*argp[0] == 'd' ||
+ ((*argp)[0] == '-' && (*argp)[1] == 'd'))) {
+ removefile(drft);
+ } else {
+ if (stat(drft, &st) != NOTOK)
+ advise(NULL, "draft left on %s", drft);
+ }
+ done(1);
+
+ case DELETESW:
+ /* Delete draft and exit */
+ removefile(drft);
+ done(1);
+
+ case PUSHSW:
+ /* Send draft in background */
+ if (sendfile(++argp, drft, 1))
+ done(1);
+ break;
+
+ case SENDSW:
+ /* Send draft */
+ sendfile(++argp, drft, 0);
+ break;
+
+ case REFILEOPT:
+ /* Refile the draft */
+ if (refile(++argp, drft) == 0)
+ done(0);
+ break;
+
+ case CDCMDSW:
+ /*
+ ** Change the working directory for attachments
+ **
+ ** Run the directory through the user's shell
+ ** so that we can take advantage of any syntax
+ ** that the user is accustomed to. Read back
+ ** the absolute path.
+ */
+
+ if (*(argp+1) == (char *)0) {
+ (void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
+ } else {
+ writesomecmd(buf, BUFSIZ, "cd", "pwd", argp);
+ }
+ if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) {
+ fgets(cwd, sizeof (cwd), f);
+
+ if (strchr(cwd, '\n') != (char *)0)
+ *strchr(cwd, '\n') = '\0';
+
+ pclose(f);
+ } else {
+ advise("popen", "could not get directory");
+ }
+
+ break;
+
+ case PWDCMDSW:
+ /* Print the working directory for attachments */
+ printf("%s\n", cwd);
+ break;
+
+ case LSCMDSW:
+ /*
+ ** List files in the current attachment working
+ ** directory
+ **
+ ** Use the user's shell so that we can take
+ ** advantage of any syntax that the user is
+ ** accustomed to.
+ */
+ writelscmd(buf, sizeof(buf), argp);
+ (void)system_in_dir(cwd, buf);
+ break;
+
+ case ALISTCMDSW:
+ /*
+ ** List attachments on current draft. Options are:
+ **
+ ** -l long listing (full path names)
+ ** -n numbers listing
+ */
+
+ if (attach == (char *)0) {
+ advise((char *)0, "can't list because no header field name was given.");
+ break;
+ }
+
+ l = (char *)0;
+ n = 0;
+
+ while (*++argp != (char *)0) {
+ if (strcmp(*argp, "-l") == 0)
+ l = "/";
+
+ else if (strcmp(*argp, "-n") == 0)
+ n = 1;
+
+ else if (strcmp(*argp, "-ln") == 0 ||
+ strcmp(*argp, "-nl") == 0) {
+ l = "/";
+ n = 1;
+ } else {
+ n = -1;
+ break;
+ }
+ }
+
+ if (n == -1)
+ advise((char *)0, "usage is alist [-ln].");
+
+ else
+ annolist(drft, attach, l, n);
+
+ break;
+
+ case ATTACHCMDSW:
+ /*
+ ** Attach files to current draft.
+ */
+
+ if (attach == (char *)0) {
+ advise((char *)0, "can't attach because no header field name was given.");
+ break;
+ }
+
+ if (*(argp+1) == (char *)0) {
+ advise((char *)0, "attach command requires file argument(s).");
+ break;
+ }