notmuch: Fix setup so that accepting the default mail path works.
authorCarl Worth <cworth@cworth.org>
Tue, 20 Oct 2009 20:16:16 +0000 (13:16 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 20 Oct 2009 20:17:56 +0000 (13:17 -0700)
The recent change from GIOChannel to getline, (with a semantic
change of the newline terminator now being included in the
result that setup_command sees), broke this.

notmuch.c

index 966901f04b1c42b8affcfe23496b61eab3e4f6bc..1ebd613eb3c95ede50914f2647fc9e5bb81f68d4 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -289,13 +289,17 @@ setup_command (int argc, char *argv[])
     getline (&mail_directory, &line_size, stdin);
     printf ("\n");
 
+    if (mail_directory &&
+       mail_directory[strlen(mail_directory)-1] == '\n')
+    {
+       mail_directory[strlen(mail_directory)-1] = '\0';
+    }
+
     if (mail_directory == NULL || strlen (mail_directory) == 0) {
        if (mail_directory)
            free (mail_directory);
        mail_directory = default_path;
     } else {
-       if (mail_directory[strlen(mail_directory)-1] == '\n')
-           mail_directory[strlen(mail_directory)-1] = '\0';
        /* XXX: Instead of telling the user to use an environment
         * variable here, we should really be writing out a configuration
         * file and loading that on the next run. */