]> diplodocus.org Git - nmh/commitdiff
Instead of relying on invo_name to decide whether to call
authorDavid Levine <levinedl@acm.org>
Thu, 29 Sep 2016 15:40:10 +0000 (11:40 -0400)
committerDavid Levine <levinedl@acm.org>
Thu, 29 Sep 2016 15:58:31 +0000 (11:58 -0400)
nmh_version_changed(), use a read_context setting of 1.

21 files changed:
h/prototypes.h
sbr/utils.c
test/install-mh/test-version-check
uip/ap.c
uip/dp.c
uip/fmtdump.c
uip/mhbuild.c
uip/mhfixmsg.c
uip/mhical.c
uip/mhl.c
uip/mhparam.c
uip/mhpath.c
uip/mkstemp.c
uip/prompter.c
uip/rcvdist.c
uip/rcvpack.c
uip/rcvstore.c
uip/rcvtty.c
uip/viamail.c
uip/whatnow.c
uip/whom.c

index a44ccbf..5252a0a 100644 (file)
@@ -497,8 +497,18 @@ void init_credentials_file ();
 int nmh_get_credentials (char *, char *, int, nmh_creds_t);
 
 /*
 int nmh_get_credentials (char *, char *, int, nmh_creds_t);
 
 /*
- * temporary file management
+ * program initialization
+ *
+ * argv0:        argv[0], presumably the program name
+ * read_context: 0: don't read context
+ *               1: read context, check nmh version, and issue warning message
+ *                  if non-existent or old
+ *               2: read context, don't check nmh version
  */
 int nmh_init(const char *argv0, int read_context);
  */
 int nmh_init(const char *argv0, int read_context);
+
+/*
+ * temporary file management
+ */
 int m_unlink(const char *);
 void unregister_for_removal(int remove_files);
 int m_unlink(const char *);
 void unregister_for_removal(int remove_files);
index 6fc6f53..f103167 100644 (file)
@@ -371,27 +371,9 @@ nmh_init(const char *argv0, int read_context) {
 
         /* Check to see if the user is running a different version of nmh
            than they had last run, and notify them if so.  But only if
 
         /* Check to see if the user is running a different version of nmh
            than they had last run, and notify them if so.  But only if
-           they seem to be running an interactive program. */
-        if (isatty (fileno (stdin))  &&  isatty (fileno (stdout))  &&
-            isatty (fileno (stderr))  &&
-            strcmp (invo_name, "ap")  &&
-            strcmp (invo_name, "dp")  &&
-            strcmp (invo_name, "fmtdump")  &&
-            strcmp (invo_name, "install-mh")  &&
-            strcmp (invo_name, "mhbuild")  &&
-            strcmp (invo_name, "mhfixmsg")  &&
-            strcmp (invo_name, "mhl")  &&
-            strcmp (invo_name, "mhparam")  &&
-            strcmp (invo_name, "mhpath")  &&
-            strcmp (invo_name, "mkstemp")  &&
-            strcmp (invo_name, "post")  &&
-            strcmp (invo_name, "prompter")  &&
-            strncmp (invo_name, "rcv", 3)  &&
-            strcmp (invo_name, "slocal")  &&
-            strcmp (invo_name, "viamail")  &&
-            strcmp (invo_name, "whatnow")  &&
-            strcmp (invo_name, "whom")) {
-
+           read_context was set to a value to enable this. */
+        if (read_context == 1  &&  isatty (fileno (stdin))  &&
+            isatty (fileno (stdout))  &&  isatty (fileno (stderr))) {
             if (nmh_version_changed ()) {
                 printf ("==================================================="
                         "====================\n");
             if (nmh_version_changed ()) {
                 printf ("==================================================="
                         "====================\n");
index f2fbe6c..3dfef04 100755 (executable)
@@ -22,13 +22,22 @@ require_prog script
 actual="$MH_TEST_DIR/test-version-check$$.actual"
 context="${MH_TEST_DIR}"/Mail/context
 
 actual="$MH_TEST_DIR/test-version-check$$.actual"
 context="${MH_TEST_DIR}"/Mail/context
 
-
-start_test 'with welcome message'
 # Removing Version will trigger the welcome message.
 grep -v Version "$context" > "$context.NEW"
 mv -f "$context.NEW" "$context"
 # Removing Version will trigger the welcome message.
 grep -v Version "$context" > "$context.NEW"
 mv -f "$context.NEW" "$context"
-# The will command wait for the user to hit return.  script seems to do what
-# we want, continue, when run in the background.
+
+
+start_test 'mhparam skips the welcome message'
+# The command will wait for the user to hit return.  script seems to do what
+# we want by not waiting when run in the background.
+script -c 'mhparam path last' -f -q "$actual" >/dev/null &
+wait $!
+grep 'Welcome to nmh version ' "$actual" >/dev/null  &&  false
+rm "$actual"
+finish_test
+
+
+start_test 'with welcome message'
 script -c 'pick last' -f -q "$actual" >/dev/null &
 wait $!
 grep 'Welcome to nmh version ' "$actual" >/dev/null
 script -c 'pick last' -f -q "$actual" >/dev/null &
 wait $!
 grep 'Welcome to nmh version ' "$actual" >/dev/null
index 9250b08..0b57e65 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -53,7 +53,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], **argp;
     char **arguments, *addrs[NADDRS];
 
     char buf[BUFSIZ], **argp;
     char **arguments, *addrs[NADDRS];
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     mts_init ();
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init ();
     arguments = getarguments (invo_name, argc, argv, 1);
index cf8f9b1..097b961 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
@@ -50,7 +50,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], **argp, **arguments;
     char *dates[NDATES];
 
     char buf[BUFSIZ], **argp, **arguments;
     char *dates[NDATES];
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index a45ea80..3cf18d3 100644 (file)
@@ -51,7 +51,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], *nfs, **argp, **arguments;
     struct format *fmt;
 
     char buf[BUFSIZ], *nfs, **argp, **arguments;
     struct format *fmt;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 87252a7..b111df0 100644 (file)
@@ -114,7 +114,7 @@ main (int argc, char **argv)
     int header_encoding = CE_UNKNOWN;
     size_t n;
 
     int header_encoding = CE_UNKNOWN;
     size_t n;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     done=unlink_done;
 
 
     done=unlink_done;
 
index 4ececa5..4262276 100644 (file)
@@ -148,7 +148,7 @@ main (int argc, char **argv) {
     fx.lf_line_endings = 0;
     fx.textcharset = NULL;
 
     fx.lf_line_endings = 0;
     fx.textcharset = NULL;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     done = freects_done;
 
 
     done = freects_done;
 
index 324d4b6..70f96dd 100644 (file)
@@ -76,7 +76,7 @@ main (int argc, char *argv[]) {
 
     icaldebug = 0;  /* Global provided by bison (with name-prefix "ical"). */
 
 
     icaldebug = 0;  /* Global provided by bison (with name-prefix "ical"). */
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 652fb11..e945f32 100644 (file)
--- a/uip/mhl.c
+++ b/uip/mhl.c
@@ -13,7 +13,7 @@
 int
 main (int argc, char **argv)
 {
 int
 main (int argc, char **argv)
 {
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     done (mhl (argc, argv));
     return 1;
 
     done (mhl (argc, argv));
     return 1;
index 3b259e7..a2a7489 100644 (file)
@@ -145,7 +145,7 @@ main(int argc, char **argv)
     char *cp, buf[BUFSIZ], **argp;
     char **arguments, *comps[MAXARGS];
 
     char *cp, buf[BUFSIZ], **argp;
     char **arguments, *comps[MAXARGS];
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index b9506d7..9ab9439 100644 (file)
@@ -32,7 +32,7 @@ main(int argc, char **argv)
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
     struct msgs_array msgs = { 0, 0, NULL };
     struct msgs *mp;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 8139fec..259c3ed 100644 (file)
@@ -150,7 +150,7 @@ process_args(int argc, char **argv, const char **directory,
     NMH_UNUSED(suffix);
 #   endif /* ! HAVE_MKSTEMPS */
 
     NMH_UNUSED(suffix);
 #   endif /* ! HAVE_MKSTEMPS */
 
-    if (nmh_init(argv[0], 1)) { done(NOTOK); }
+    if (nmh_init(argv[0], 2)) { done(NOTOK); }
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
index 58347d4..f5332e4 100644 (file)
@@ -78,7 +78,7 @@ main (int argc, char **argv)
     char *tmpfil;
     m_getfld_state_t gstate = 0;
 
     char *tmpfil;
     m_getfld_state_t gstate = 0;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
index 7e9ae01..29b341c 100644 (file)
@@ -48,7 +48,7 @@ main (int argc, char **argv)
     FILE *fp;
     char *tfile = NULL;
 
     FILE *fp;
     char *tfile = NULL;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     done=unlink_done;
 
 
     done=unlink_done;
 
index 2553e82..df504a8 100644 (file)
@@ -40,7 +40,7 @@ main (int argc, char **argv)
     char *cp, *file = NULL, buf[BUFSIZ];
     char **argp, **arguments;
 
     char *cp, *file = NULL, buf[BUFSIZ];
     char **argp, **arguments;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     mts_init ();
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init ();
     arguments = getarguments (invo_name, argc, argv, 1);
index a7d3a9e..8d11e00 100644 (file)
@@ -54,7 +54,7 @@ main (int argc, char **argv)
     struct msgs *mp;
     struct stat st;
 
     struct msgs *mp;
     struct stat st;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     done=unlink_done;
 
 
     done=unlink_done;
 
index ab674f0..d32a1ba 100644 (file)
@@ -82,7 +82,7 @@ main (int argc, char **argv)
     char **argp, **arguments, *vec[MAXARGS];
     struct utmpx *utp;
 
     char **argp, **arguments, *vec[MAXARGS];
     struct utmpx *utp;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     mts_init ();
     arguments = getarguments (invo_name, argc, argv, 1);
 
     mts_init ();
     arguments = getarguments (invo_name, argc, argv, 1);
index f80980d..1514ef8 100644 (file)
@@ -56,7 +56,7 @@ main (int argc, char **argv)
     char *cp, buf[BUFSIZ];
     char **argp, **arguments;
 
     char *cp, buf[BUFSIZ];
     char **argp, **arguments;
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 0);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 0);
     argp = arguments;
index 031ff3c..9f30590 100644 (file)
@@ -13,7 +13,7 @@
 int
 main (int argc, char **argv)
 {
 int
 main (int argc, char **argv)
 {
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     return WhatNow (argc, argv);
 }
 
     return WhatNow (argc, argv);
 }
index b1e8b1e..688950c 100644 (file)
@@ -63,7 +63,7 @@ main (int argc, char **argv)
     char *msg = NULL, **ap, **argp, backup[BUFSIZ];
     char buf[BUFSIZ], **arguments, *vec[MAXARGS];
 
     char *msg = NULL, **ap, **argp, backup[BUFSIZ];
     char buf[BUFSIZ], **arguments, *vec[MAXARGS];
 
-    if (nmh_init(argv[0], 1)) { return 1; }
+    if (nmh_init(argv[0], 2)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;