test/inc/test-deb359167 test/inc/test-eom-align \
test/inc/test-inc-scanout test/inc/test-msgchk \
test/inc/test-pop \
- test/install-mh/test-install-mh \
+ test/install-mh/test-install-mh test/install-mh/test-version-check \
test/locking/test-datalocking test/locking/test-spoollocking \
test/manpages/test-manpages \
test/mhbuild/test-attach \
- If a message body contains 8-bit bytes, post(8) uses SMTP 8BITMIME if the
server supports it. If not, post fails with a message to the user to
encode the message for 7-bit transport.
+- Added welcome message when nmh detects that its version changed.
-----------------
OBSOLETE FEATURES
int writeBase64raw (const unsigned char *, size_t, unsigned char *);
/*
- * first argument: the string to be decoded
- * second argument: the decoded bytes
- * third argument: number of decoded bytes
- * fourth argument: non-zero for text content, and for which CR's should be skipped
- * fifth argument: for an MD5 digest, it can be null
+ * encoded - the string to be decoded
+ * decoded - the decoded bytes
+ * len - number of decoded bytes
+ * skip-crs - non-zero for text content, and for which CR's should be
+ * skipped
+ * digest - for an MD5 digest, it can be null
*/
-int decodeBase64 (const char *, unsigned char **, size_t *, int,
- unsigned char *);
+int decodeBase64 (const char *encoded, unsigned char **decoded, size_t *len,
+ int skip_crs, unsigned char *digest);
void hexify (const unsigned char *, size_t, char **);
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);
+
+/*
+ * temporary file management
+ */
int m_unlink(const char *);
void unregister_for_removal(int remove_files);
* Returns 1 if the string contains an 8-bit character, 0 if it does not.
*/
int contains8bit(const char *start, const char *end);
+
+/*
+ * Compares prior version of nmh with current version. Returns 1
+ * if they compare the be the same, 0 if not.
+ *
+ * older - 0 for difference comparison, 1 for only if older
+ */
+int nmh_version_changed (int older);
-.TH MH-PROFILE %manext5% "December 21, 2014" "%nmhversion%"
+.TH MH-PROFILE %manext5% "September 29, 2016" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
caution and only when absolutely necessary.
(profile, default: legacy)
.RE
+.PP
+.BR Welcome :
+disable
+.RS 5
+If the Welcome component is not present, or its value is not
+.RI \*(lq disable \*(rq,
+a welcome message will be displayed the first time that an interactive
+.B nmh
+program is run after updating the
+.B nmh
+installation.
+The user must press the Enter key to continue.
+.PP
+If the MHCONTEXT environment variable is set and non-empty (and
+the Welcome component is not
+.RI \*(lq disable \*(rq),
+the welcome message is only displayed if the context file contains a version
+reference, and that reference is older than the installed
+.B nmh
+version. The version reference is of the form:
+.PP
+.RS 5
+.nf
+Version: %nmhversion%
+.fi
+.RE
+.PP
+.RE
.SS "Process Profile Entries"
The following profile elements are used whenever an
.B nmh
*/
static const char nmh_intro1[] = \
-"Send bug reports, questions, suggestions, and patches to nmh-\n"
-"workers@nongnu.org. That mailing list is relatively quiet, so user\n"
+"Send bug reports, questions, suggestions, and patches to\n"
+"nmh-workers@nongnu.org. That mailing list is relatively quiet, so user\n"
"questions are encouraged. Users are also encouraged to subscribe, and\n"
"view the archives, at https://lists.gnu.org/mailman/listinfo/nmh-\n"
"workers .\n";
/* sbr/m_mktemp.c */
extern void remove_registered_files_atexit();
+extern char *mhdocdir;
/*
* We allocate space for messages (msgs array)
admonish("atexit", "unable to register atexit function");
}
+ /* Read context, if supposed to. */
if (read_context) {
+ int allow_version_check = 1;
+ int check_older_version = 0;
+ char *cp;
+
context_read();
+
+ if (read_context != 1 ||
+ ((cp = context_find ("Welcome")) && strcasecmp (cp, "disable") == 0)) {
+ allow_version_check = 0;
+ } else if ((cp = getenv ("MHCONTEXT")) != NULL && *cp != '\0') {
+ /* Context file comes from $MHCONTEXT, so only print the message
+ if the context file has an older version. If it does, or if it
+ doesn't have a version at all, update the version. */
+ check_older_version = 1;
+ }
+
+ /* Check to see if the user is running a different (or older, if
+ specified) version of nmh than they had run bfore, and notify them
+ if so. But only if read_context was set to a value to enable. */
+ if (allow_version_check && isatty (fileno (stdin)) &&
+ isatty (fileno (stdout)) && isatty (fileno (stderr))) {
+ if (nmh_version_changed (check_older_version)) {
+ printf ("==================================================="
+ "====================\n");
+ printf ("Welcome to nmh version %s\n\n", VERSION);
+ printf ("See the release notes in %s/NEWS .\n\n",
+ mhdocdir);
+ print_intro (stdout, 1);
+ printf ("\nThis message will not be repeated until "
+ "nmh is next updated.\n");
+ printf ("==================================================="
+ "====================\n\n");
+
+ fputs ("Press enter to continue: ", stdout);
+ (void) read_line ();
+ putchar ('\n');
+ }
+ }
+
return OK;
} else {
int status = context_foil(NULL);
}
+/*
+ * Check stored version, and return 1 if out-of-date or non-existent.
+ * Because the output of "mhparam version" is prefixed with "nmh-",
+ * use that prefix here.
+ */
+int
+nmh_version_changed (int older) {
+ const char *const context_version = context_find("Version");
+
+ if (older) {
+ /* Convert the version strings to floats and compare them. This will
+ break for versions with multiple decimal points, etc. */
+ const float current_version = strtod (VERSION, NULL);
+ const float old_version =
+ context_version && strncmp (context_version, "nmh-", 4) == 0
+ ? strtof (context_version + 4, NULL)
+ : 99999999;
+
+ if (context_version == NULL || old_version < current_version) {
+ context_replace ("Version", "nmh-" VERSION);
+ }
+
+ return old_version < current_version ? 1 : 0;
+ } else {
+ if (context_version == NULL || strcmp(context_version, "nmh-" VERSION) != 0) {
+ context_replace ("Version", "nmh-" VERSION);
+
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+}
+
+
/* Returns copy of argument str with all characters converted to upper
case, and trimmed whitespace (see cpytrim()) . */
char *
whomproc: ${MH_INST_DIR}${bindir}/whom
#: incproc and packproc are defined in config.c but not used by any code.
EOF
- #### Suppress warnings about a new version.
- printf '%s\n' ${MH_VERSION} > ${MH_TEST_DIR}/Mail/VERSION
if test -z '@nmhetcdirinst@'; then
#### This isn't used with make distcheck, so that we can use it to
fi
folder -create +inbox > /dev/null
+ #### Suppress warnings about a new version.
+ #### mhparam version includes the nmh- prefix, so be consistent with that.
+ printf 'Version: nmh-%s\n' "${MH_VERSION}" >> "${MH_TEST_DIR}"/Mail/context
+
# create 10 basic messages
for i in 1 2 3 4 5 6 7 8 9 10;
do
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test display of new version welcome message. This
+# doesn't really belong in install-mh.
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "${MH_OBJ_DIR}/test/common.sh"
+
+setup_test
+
+require_prog script
+
+actual="$MH_TEST_DIR/test-version-check$$.actual"
+context="${MH_TEST_DIR}"/Mail/context
+version="Version: nmh-${MH_VERSION}"
+
+# Removing Version will trigger the welcome message. (setup_test
+# inserted it so that other tests wouldn't show it.)
+grep -v Version "$context" > "$context.NEW"
+mv -f "$context.NEW" "$context"
+
+
+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"
+# Make sure that version wasn't added to context.
+grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
+finish_test
+
+
+start_test 'Welcome: disable in profile skips the welcome message'
+cp "${MH}" "${MH}-welcome"
+printf 'Welcome: disable\n' >> "${MH}-welcome"
+MH="${MH}-welcome" script -c 'pick last' -f -q "$actual" >/dev/null &
+wait $!
+grep 'Welcome to nmh version ' "$actual" >/dev/null && false
+rm "$actual"
+# Make sure that version wasn't added to context.
+grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null && false
+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
+rm "$actual"
+# Make sure that version was added to context.
+grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
+finish_test
+
+
+start_test 'without welcome message'
+# After running the previous test, this one should not have
+# the welcome message.
+script -c 'pick last' -f -q "$actual" >/dev/null &
+wait $!
+grep 'Welcome to nmh version ' "$actual" >/dev/null && false
+rm "$actual"
+# Make sure that version is still in context.
+grep "^${version}$" "${MH_TEST_DIR}/Mail/context" >/dev/null
+finish_test
+
+
+start_test 'with MHCONTEXT, welcome only if older'
+MHCONTEXT="${MH_TEST_DIR}/Mail/context2"; export MHCONTEXT
+printf 'Version: nmh-1.5\n' >"${MHCONTEXT}"
+script -c 'pick last' -f -q "$actual" >/dev/null &
+wait $!
+grep 'Welcome to nmh version ' "$actual" >/dev/null
+# And make sure that version did get updated in context.
+grep "^${version}$" "${MHCONTEXT}" >/dev/null
+rm "$actual"
+finish_test
+
+
+start_test "with MHCONTEXT doesn't welcome if newer"
+printf 'Version: nmh-10000.0\n' >"${MHCONTEXT}"
+script -c 'pick last' -f -q "$actual" >/dev/null &
+wait $!
+grep 'Welcome to nmh version ' "$actual" >/dev/null && false
+rm "$actual"
+# And make sure that version didn't get updated in context.
+grep '^Version: nmh-10000.0$' "${MHCONTEXT}" >/dev/null
+finish_test
+
+
+start_test 'with MHCONTEXT but no version, no welcome and update'
+printf '' >"${MHCONTEXT}"
+script -c 'pick last' -f -q "$actual" >/dev/null &
+wait $!
+grep 'Welcome to nmh version ' "$actual" >/dev/null && false
+# And make sure that version did get updated in context.
+grep "^${version}$" "${MHCONTEXT}" >/dev/null
+rm "$actual"
+finish_test
+
+
+exit $failed
# check -all
cp "$MH" $expected
-# -all adds current folder
+# -all adds current folder and Version
echo 'Current-Folder: '`folder -f` >>$expected
+echo "Version: nmh-$MH_VERSION" >>$expected
run_prog mhparam -all >$actual
check $expected $actual 'keep first'
$MH_INST_DIR$bindir/send
$MH_INST_DIR$bindir/mhshow
$MH_INST_DIR$nmhlibexecdir/mhl
-nmh-`cat ${srcdir}/VERSION`
+nmh-$MH_VERSION
$MH_INST_DIR$bindir/whatnow
$MH_INST_DIR$bindir/whom
$nmhetcdirinst
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);
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;
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;
puts ("\nPlease see the nmh(7) man page for an introduction to nmh.\n");
print_intro (stdout, FALSE);
+ /* Initialize the saved nmh version. The Path profile entry was added
+ above, that's all this needs. */
+ (void) nmh_version_changed (0);
+
done (0);
return 1;
}
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;
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;
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;
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;
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;
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;
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;
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;
FILE *fp;
char *tfile = NULL;
- if (nmh_init(argv[0], 1)) { return 1; }
+ if (nmh_init(argv[0], 2)) { return 1; }
done=unlink_done;
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);
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;
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);
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;
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);
}
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;