--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id CC9F66DE1AE1\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Apr 2015 05:23:55 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.481\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.481 tagged_above=-999 required=5 tests=[AWL=0.471, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id Glgyw6EqjGo2 for <notmuch@notmuchmail.org>;\r
+ Mon, 6 Apr 2015 05:23:53 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 12FE16DE1AC6\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Apr 2015 05:23:52 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1Yf63a-00058n-9J; Mon, 06 Apr 2015 12:23:10 +0000\r
+Received: (nullmailer pid 3269 invoked by uid 1000); Mon, 06 Apr 2015\r
+ 12:22:52 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: argument parsing refactoring, round 2\r
+Date: Mon, 6 Apr 2015 21:22:34 +0900\r
+Message-Id: <1428322958-2887-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <87d23ixnr7.fsf@maritornes.cs.unb.ca>\r
+References: <87d23ixnr7.fsf@maritornes.cs.unb.ca>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 06 Apr 2015 12:23:56 -0000\r
+\r
+Thanks to Mark for pointing out on IRC that the previous version had problems linking the test suite helpers. That's fixed here by adding a couple stubs.\r
+\r
+Here's the diff, roughly with the previous version (actually the first\r
+hunk is with a slightly later version, where I fixed one bug and\r
+introduced another).\r
+\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index 568b3dc..f2cd6a8 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -885,9 +885,9 @@ notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])\r
+ \r
+ notmuch_process_shared_options (argv[0]);\r
+ \r
+- /* skip subcommand argument */\r
+- argc-= opt_index+1;\r
+- argv+= opt_index+1;\r
++ /* skip at least subcommand argument */\r
++ argc-= opt_index;\r
++ argv+= opt_index;\r
+ \r
+ if (argc < 1) {\r
+ fprintf (stderr, "Error: notmuch config requires at least one argument.\n");\r
+diff --git a/notmuch-setup.c b/notmuch-setup.c\r
+index 5fc6e25..6a020dc 100644\r
+--- a/notmuch-setup.c\r
++++ b/notmuch-setup.c\r
+@@ -155,7 +155,7 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ if (opt_index < 0)\r
+ return EXIT_FAILURE;\r
+ \r
+- notmuch_process_shared_options (argv[0]);\r
++ notmuch_process_shared_options ("setup");\r
+ \r
+ if (notmuch_config_is_new (config))\r
+ welcome_message_pre_setup ();\r
+diff --git a/test/random-corpus.c b/test/random-corpus.c\r
+index 790193d..6c467bb 100644\r
+--- a/test/random-corpus.c\r
++++ b/test/random-corpus.c\r
+@@ -114,6 +114,15 @@ random_utf8_string (void *ctx, size_t char_count)\r
+ return buf;\r
+ }\r
+ \r
++/* stubs since we cannot link with notmuch.o */\r
++const notmuch_opt_desc_t notmuch_shared_options[] = {\r
++ { 0, 0, 0, 0, 0 }\r
++};\r
++\r
++void\r
++notmuch_process_shared_options (unused (const char *dummy))\r
++{\r
++}\r
+ \r
+ int\r
+ main (int argc, char **argv)\r