diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-20 09:56:25 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-20 09:58:40 -0700 |
commit | 55c8ee9a862f8f25be84adb591564b3777d88135 (patch) | |
tree | a59eb08ca8615a241c621404007f6d7a9f6c2cf2 /notmuch.c | |
parent | ed6ee7330d28c65cb3990cbe4a5ac6182bf23402 (diff) |
notmuch_database_create/open: Fix to handle NULL as documented.
When documenting these functions I described support for a
NOTMUCH_BASE environment variable to be consulted in the case
of a NULL path. Only, I had forgotten to actually write the
code.
This code exists now, with a new, exported function:
notmuch_database_default_path
Diffstat (limited to 'notmuch.c')
-rw-r--r-- | notmuch.c | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -310,25 +310,19 @@ setup_command (int argc, char *argv[]) "such as mb2md. In that case, press Control-C now and run notmuch again\n" "once the conversion is complete.\n\n"); - printf ("Top-level mail directory [~/mail]: "); - fflush (stdout); + { + char *default_path = notmuch_database_default_path (); + printf ("Top-level mail directory [%s]: ", default_path); + free (default_path); + fflush (stdout); + } mail_directory = read_line (); if (mail_directory == NULL || strlen (mail_directory) == 0) { - char *home; - if (mail_directory) free (mail_directory); - - home = getenv ("HOME"); - if (!home) { - fprintf (stderr, "Error: No mail directory provided HOME environment variable is not set.\n"); - fprintf (stderr, "Cowardly refusing to just guess where your mail might be.\n"); - exit (1); - } - - mail_directory = g_strdup_printf ("%s/mail", home); + mail_directory = notmuch_database_default_path (); } notmuch = notmuch_database_create (mail_directory); |