This makes `notmuch --config foo external-subcommand` work
consistently with the built in subcommands.
---
notmuch.c | 11 +++++++++--
test/T405-external.sh | 1 -
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/notmuch.c b/notmuch.c
index ac25ae18..8398501f 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -443,11 +443,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);
/*
@@ -507,7 +514,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;
diff --git a/test/T405-external.sh b/test/T405-external.sh
index b121fc72..0e1d9646 100755
--- a/test/T405-external.sh
+++ b/test/T405-external.sh
@@ -44,7 +44,6 @@ EOF
test_expect_equal_file_nonempty EXPECTED OUTPUT
test_begin_subtest "NOTMUCH_CONFIG is set by --config"
-test_subtest_known_broken
cp "${NOTMUCH_CONFIG}" "${NOTMUCH_CONFIG}.alternate"
cat <<EOF > EXPECTED
${NOTMUCH_CONFIG}.alternate
--
2.35.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org