]> diplodocus.org Git - nmh/commitdiff
Add MAX_EXIT, value 120, to limit some more exit(3) values.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 27 Aug 2017 09:16:11 +0000 (10:16 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 27 Aug 2017 09:16:11 +0000 (10:16 +0100)
mhparam(1) altered to use new macro.  ap(1) and dp(1) now limit.

h/mh.h
uip/ap.c
uip/dp.c
uip/mhparam.c

diff --git a/h/mh.h b/h/mh.h
index bebe8b8..75812a3 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
 #define DMAXFOLDER     4       /* typical number of digits             */
 #define MAXFOLDER   1000       /* message increment                    */
 
+/* non-zero exit(3) values indicating the number of errors need to be
+ * capped else they interfere with the shell's use of high seven-bit
+ * values, and the shell's mapping of signals onto top-bit-set values.
+ * Plus, every so often the eight-bit value will wrap to zero, wrongly
+ * indicating success. */
+#define MAX_EXIT 120
+
 /*
  * This macro is for use by scan, for example, so that platforms with
  * a small BUFSIZ can easily allocate larger buffers.
index ea93fd6..a44ecf5 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -127,7 +127,7 @@ main (int argc, char **argv)
        status += process (addrs[addrp], width);
 
     fmt_free (fmt, 1);
-    done (status);
+    done(min(status, MAX_EXIT));
     return 1;
 }
 
index 56a0ae1..ece04a3 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
@@ -123,7 +123,7 @@ main (int argc, char **argv)
 
     context_save ();   /* save the context file */
     fmt_free (fmt, 1);
-    done (status);
+    done(min(status, MAX_EXIT));
     return 1;
 }
 
index 17705bc..4aadec5 100644 (file)
@@ -253,7 +253,7 @@ main(int argc, char **argv)
                    printf("%s: ", comps[i]);
 
                puts(value);
-           } else if (missed < 120)
+           } else if (missed < MAX_EXIT)
                missed++;
        }
     }