mhmail: Don't invoke inc when called without arguments.
[mmh] / uip / mhmail.c
index c7a7afa..72771a7 100644 (file)
@@ -54,16 +54,15 @@ main(int argc, char **argv)
 #ifdef LOCALE
        setlocale(LC_ALL, "");
 #endif
-       invo_name = r1bindex(argv[0], '/');
+       invo_name = mhbasename(argv[0]);
 
        /* foil search of user profile/context */
        if (context_foil(NULL) == -1)
                done(1);
 
-       /* If no arguments, just incorporate new mail */
+       /* Without arguments, exit. */
        if (argc == 1) {
-               execlp(incproc, r1bindex(incproc, '/'), NULL);
-               adios(incproc, "unable to exec");
+               adios(NULL, "no interactive mail shell. Use inc/scan/show instead.");
        }
 
        arguments = getarguments(invo_name, argc, argv, 0);
@@ -72,46 +71,51 @@ main(int argc, char **argv)
        while ((cp = *argp++)) {
                if (*cp == '-') {
                        switch (smatch(++cp, switches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, switches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "-%s unknown", cp);
-
-                               case HELPSW:
-                                       snprintf(buf, sizeof(buf), "%s [addrs ... [switches]]", invo_name);
-                                       print_help(buf, switches, 0);
-                                       done(1);
-                               case VERSIONSW:
-                                       print_version(invo_name);
-                                       done(1);
-
-                               case FROMSW:
-                                       if (!(from = *argp++) || *from == '-')
-                                               adios(NULL, "missing argument to %s", argp[-2]);
-                                       continue;
-
-                               case BODYSW:
-                                       if (!(body = *argp++) || *body == '-')
-                                               adios(NULL, "missing argument to %s", argp[-2]);
-                                       continue;
-
-                               case CCSW:
-                                       iscc++;
-                                       continue;
-
-                               case SUBJSW:
-                                       if (!(subject = *argp++) || *subject == '-')
-                                               adios(NULL, "missing argument to %s", argp[-2]);
-                                       continue;
-
-                               case RESNDSW:
-                                       resent++;
-                                       continue;
-
-                               case QUEUESW:
-                                       queued++;
-                                       continue;
+                       case AMBIGSW:
+                               ambigsw(cp, switches);
+                               done(1);
+                       case UNKWNSW:
+                               adios(NULL, "-%s unknown", cp);
+
+                       case HELPSW:
+                               snprintf(buf, sizeof(buf),
+                                               "%s addrs... [switches]",
+                                               invo_name);
+                               print_help(buf, switches, 0);
+                               done(1);
+                       case VERSIONSW:
+                               print_version(invo_name);
+                               done(1);
+
+                       case FROMSW:
+                               if (!(from = *argp++) || *from == '-')
+                                       adios(NULL, "missing argument to %s",
+                                                       argp[-2]);
+                               continue;
+
+                       case BODYSW:
+                               if (!(body = *argp++) || *body == '-')
+                                       adios(NULL, "missing argument to %s",
+                                                       argp[-2]);
+                               continue;
+
+                       case CCSW:
+                               iscc++;
+                               continue;
+
+                       case SUBJSW:
+                               if (!(subject = *argp++) || *subject == '-')
+                                       adios(NULL, "missing argument to %s",
+                                                       argp[-2]);
+                               continue;
+
+                       case RESNDSW:
+                               resent++;
+                               continue;
+
+                       case QUEUESW:
+                               queued++;
+                               continue;
                        }
                }
                if (iscc)
@@ -125,7 +129,7 @@ main(int argc, char **argv)
        if (tolist == NULL)
                adios(NULL, "usage: %s addrs ... [switches]", invo_name);
 
-       tfile = m_mktemp2(NULL, invo_name, NULL, &out);
+       tfile = m_mktemp2("/tmp/", invo_name, NULL, &out);
        if (tfile == NULL)
                adios("mhmail", "unable to create temporary file");
        chmod(tfile, 0600);
@@ -135,7 +139,7 @@ main(int argc, char **argv)
 
        fprintf(out, "%sTo: %s\n", resent ? "Resent-" : "", tolist);
        if (cclist)
-               fprintf(out, "%scc: %s\n", resent ? "Resent-" : "", cclist);
+               fprintf(out, "%sCc: %s\n", resent ? "Resent-" : "", cclist);
        if (subject)
                fprintf(out, "%sSubject: %s\n", resent ? "Resent-" : "", subject);
        if (from)
@@ -160,7 +164,7 @@ main(int argc, char **argv)
        fclose(out);
 
        nvec = 0;
-       vec[nvec++] = r1bindex(postproc, '/');
+       vec[nvec++] = mhbasename(postproc);
        vec[nvec++] = tmpfil;
        if (resent)
                vec[nvec++] = "-dist";
@@ -168,10 +172,7 @@ main(int argc, char **argv)
                vec[nvec++] = "-queued";
        vec[nvec] = NULL;
 
-       for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
-               sleep(5);
-
-       if (child_id == NOTOK) {
+       if ((child_id = fork()) == NOTOK) {
                /* report failure and then send it */
                adios(NULL, "unable to fork");
        } else if (child_id) {