X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=ac25ae189b78d049d65b70afc09e3dee031f4312;hp=c39fcfb2cb1c066e498758cde37deae65e13e99b;hb=HEAD;hpb=52470ddfbfaeac8e5530e32d45bd6259d4326517 diff --git a/notmuch.c b/notmuch.c index c39fcfb2..814b9e42 100644 --- a/notmuch.c +++ b/notmuch.c @@ -211,12 +211,14 @@ typedef struct help_topic { } help_topic_t; static const help_topic_t help_topics[] = { - { "search-terms", - "Common search term syntax." }, { "hooks", "Hooks that will be run before or after certain commands." }, { "properties", "Message property conventions and documentation." }, + { "search-terms", + "Common infix search term syntax." }, + { "sexp-queries", + "Common s-expression search term syntax." }, }; static const command_t * @@ -427,11 +429,18 @@ notmuch_command (notmuch_database_t *notmuch, * false on errors. */ static bool -try_external_command (char *argv[]) +try_external_command (const char *config_file_name, char *argv[]) { char *old_argv0 = argv[0]; bool ret = true; + if (config_file_name) { + if (setenv ("NOTMUCH_CONFIG", config_file_name, 1)) { + perror ("setenv"); + exit (1); + } + } + argv[0] = talloc_asprintf (NULL, "notmuch-%s", old_argv0); /* @@ -491,7 +500,7 @@ main (int argc, char *argv[]) /* if command->function is NULL, try external command */ if (! command || ! command->function) { /* This won't return if the external command is found. */ - if (try_external_command (argv + opt_index)) + if (try_external_command (config_file_name, argv + opt_index)) fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n", command_name); ret = EXIT_FAILURE; @@ -522,7 +531,7 @@ main (int argc, char *argv[]) } if (status == NOTMUCH_STATUS_NO_CONFIG) - fputs ("Try running 'notmuch setup' to create a configuration.", stderr); + fputs ("Try running 'notmuch setup' to create a configuration.\n", stderr); return EXIT_FAILURE; } @@ -554,15 +563,16 @@ main (int argc, char *argv[]) NULL, ¬much, &status_string); - - if (status == NOTMUCH_STATUS_NO_CONFIG && ! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) { - fputs ("Try running 'notmuch setup' to create a configuration.", stderr); - goto DONE; + if (status_string) { + fputs (status_string, stderr); + free (status_string); + status_string = NULL; } + switch (status) { case NOTMUCH_STATUS_NO_CONFIG: if (! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) { - fputs ("Try running 'notmuch setup' to create a configuration.", stderr); + fputs ("Try running 'notmuch setup' to create a configuration.\n", stderr); goto DONE; } break; @@ -580,6 +590,8 @@ main (int argc, char *argv[]) case NOTMUCH_STATUS_SUCCESS: break; default: + fputs ("Error: unable to load config file.\n", stderr); + ret = 1; goto DONE; }