From: David Levine Date: Mon, 29 Aug 2016 13:26:38 +0000 (-0400) Subject: Added warning message on stderr if folder -nocreate is provided X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b335902294f1bb9b9fdab8c8917de07a1db3d4b1?ds=sidebyside;hp=-c Added warning message on stderr if folder -nocreate is provided a non-existant folder. (cherry picked from commit d51964a51fdc08d92dab9825a8357c9adba34aa7) --- b335902294f1bb9b9fdab8c8917de07a1db3d4b1 diff --git a/Makefile.am b/Makefile.am index dbcd7c32..c4de7d1c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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/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 \ diff --git a/docs/pending-release-notes b/docs/pending-release-notes index 869befcc..37e6f70d 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -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. +- folder(1) -nocreate now prints a warning message for a non-existant folder. ----------------- OBSOLETE FEATURES diff --git a/man/folder.man b/man/folder.man index 9d86b919..92a2cf00 100644 --- a/man/folder.man +++ b/man/folder.man @@ -1,4 +1,4 @@ -.TH FOLDER %manext1% "January 1, 2001" "%nmhversion%" +.TH FOLDER %manext1% "August 29, 2016" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -80,7 +80,7 @@ use later.) Specifying .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 diff --git a/test/folder/test-nocreate b/test/folder/test-nocreate new file mode 100755 index 00000000..49b2209b --- /dev/null +++ b/test/folder/test-nocreate @@ -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} diff --git a/uip/folder.c b/uip/folder.c index fc183774..f1af6f25 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -92,6 +92,16 @@ static void print_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) @@ -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. */ - 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 */