diff options
| author | David Bremner <david@tethera.net> | 2022-05-31 08:50:59 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2022-06-13 07:28:05 -0300 |
| commit | 5cbddf7e7a96a801e5ad3482b2636aff375a0821 (patch) | |
| tree | 4e32d856d1d70734a9f3f9d4f26abe327bb7695e /notmuch.c | |
| parent | eaa5199f5bf761d3b57f7ed22e125e716446a1cb (diff) | |
CLI: pass --config to external commands via NOTMUCH_CONFIG.
This makes `notmuch --config foo external-subcommand` work
consistently with the built in subcommands.
Diffstat (limited to 'notmuch.c')
| -rw-r--r-- | notmuch.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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; |
