]> diplodocus.org Git - nmh/commitdiff
Added warning message on stderr if folder -nocreate is provided
authorDavid Levine <levinedl@acm.org>
Mon, 29 Aug 2016 13:26:38 +0000 (09:26 -0400)
committerDavid Levine <david.levine@gonift.com>
Mon, 29 Aug 2016 13:30:03 +0000 (09:30 -0400)
a non-existant folder.

(cherry picked from commit d51964a51fdc08d92dab9825a8357c9adba34aa7)

Makefile.am
docs/pending-release-notes
man/folder.man
test/folder/test-nocreate [new file with mode: 0755]
uip/folder.c

index dbcd7c3..c4de7d1 100644 (file)
@@ -55,9 +55,9 @@ TESTS = test/ali/test-ali test/anno/test-anno \
        test/bad-input/test-header \
        test/burst/test-burst test/burst/test-burst-mime \
        test/comp/test-comp-format test/dist/test-dist \
        test/bad-input/test-header \
        test/burst/test-burst test/burst/test-burst-mime \
        test/comp/test-comp-format test/dist/test-dist \
-       test/folder/test-create test/folder/test-packf \
-       test/folder/test-recurse test/folder/test-sortm \
-       test/folder/test-total \
+       test/folder/test-create test/folder/test-nocreate \
+       test/folder/test-packf test/folder/test-recurse \
+       test/folder/test-sortm test/folder/test-total \
        test/format/test-curses test/format/test-dp \
        test/format/test-fmtdump test/format/test-functions \
        test/format/test-localmbox test/format/test-myname \
        test/format/test-curses test/format/test-dp \
        test/format/test-fmtdump test/format/test-functions \
        test/format/test-localmbox test/format/test-myname \
index 869befc..37e6f70 100644 (file)
@@ -46,6 +46,7 @@ NEW FEATURES
 - Added support to send(1) to specify switches to post(1) based on address or
   domain name in From: header line in message draft.
 - post(8) -snoop now attempts to decode base64-encoded SMTP traffic.
 - Added support to send(1) to specify switches to post(1) based on address or
   domain name in From: header line in message draft.
 - post(8) -snoop now attempts to decode base64-encoded SMTP traffic.
+- folder(1) -nocreate now prints a warning message for a non-existant folder.
 
 -----------------
 OBSOLETE FEATURES
 
 -----------------
 OBSOLETE FEATURES
index 9d86b91..92a2cf0 100644 (file)
@@ -1,4 +1,4 @@
-.TH FOLDER %manext1% "January 1, 2001" "%nmhversion%"
+.TH FOLDER %manext1% "August 29, 2016" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
 .\"
 .\" %nmhwarning%
 .\"
@@ -80,7 +80,7 @@ use later.)  Specifying
 .B \-nocreate
 will cause
 .B folder
 .B \-nocreate
 will cause
 .B folder
-to exit
+to print an error message and exit
 without creating a non-existant folder.
 .\"
 .\" note - this doesn't work at present
 without creating a non-existant folder.
 .\"
 .\" note - this doesn't work at present
diff --git a/test/folder/test-nocreate b/test/folder/test-nocreate
new file mode 100755 (executable)
index 0000000..49b2209
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+######################################################
+#
+# Test -nocreate.
+#
+######################################################
+
+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
+
+set +e
+run_test 'run_prog folder -nocreate +testfolder 2>&1' \
+         'folder: folder testfolder does not exist'
+set -e
+if [ -d "$MH_TEST_DIR/Mail/testfolder" ]; then
+    printf %s "folder should not have been created"
+    exit 1
+fi
+
+exit ${failed:-0}
index fc18377..f1af6f2 100644 (file)
@@ -92,6 +92,16 @@ static void print_folders (void);
 static int sfold (struct msgs *, char *);
 static void readonly_folders (void);
 
 static int sfold (struct msgs *, char *);
 static void readonly_folders (void);
 
+/*
+ * Function for printing error message if folder does not exist with
+ * -nocreate.
+ */
+void
+nonexistant_folder (int status) {
+    NMH_UNUSED (status);
+    adios (NULL, "folder %s does not exist", folder);
+}
+
 
 int
 main (int argc, char **argv)
 
 int
 main (int argc, char **argv)
@@ -349,7 +359,7 @@ main (int argc, char **argv)
         * Check if folder exists.  If not, then see if
         * we should create it, or just exit.
         */
         * Check if folder exists.  If not, then see if
         * we should create it, or just exit.
         */
-        create_folder (m_maildir (folder), fcreat, done);
+        create_folder (m_maildir (folder), fcreat, nonexistant_folder);
 
        if (get_folder_info (folder, msg) && argfolder) {
            /* update current folder */
 
        if (get_folder_info (folder, msg) && argfolder) {
            /* update current folder */