X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=notmuch.c;h=c75b0188e7dfc901d9822558135117c404b93bde;hb=78632345868b5e4753ad402c806c29569946ce89;hp=68a785e25bf0b826a17071bc8162edefe30fb87b;hpb=82957c963296bb9d2147ce5374b940463facd9ec;p=notmuch diff --git a/notmuch.c b/notmuch.c index 68a785e2..c75b0188 100644 --- a/notmuch.c +++ b/notmuch.c @@ -429,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); /* @@ -493,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;