[PATCH 1/2] cli: fix top level --help combined with other options
authorJani Nikula <jani@nikula.org>
Sun, 8 Mar 2015 16:18:54 +0000 (18:18 +0200)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:23 +0000 (14:48 -0700)
7d/2ae620953f919e3da9165803146f2a13d38020 [new file with mode: 0644]

diff --git a/7d/2ae620953f919e3da9165803146f2a13d38020 b/7d/2ae620953f919e3da9165803146f2a13d38020
new file mode 100644 (file)
index 0000000..4d749c2
--- /dev/null
@@ -0,0 +1,98 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id D76D6431FC4\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Mar 2015 09:18:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.738\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
+       tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 1rk4IZGaBXck for <notmuch@notmuchmail.org>;\r
+       Sun,  8 Mar 2015 09:18:41 -0700 (PDT)\r
+Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com\r
+       [209.85.212.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 70177431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Mar 2015 09:18:41 -0700 (PDT)\r
+Received: by wibbs8 with SMTP id bs8so14545712wib.4\r
+       for <notmuch@notmuchmail.org>; Sun, 08 Mar 2015 09:18:39 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+       bh=FIH5gzn0PFqlR22mdDOXe+odh+2GOm/RjAm7bfM6LOg=;\r
+       b=DXtQvY64zV6uNyGlSVJGq5ES6LJC653fJtnvx6yjBGKKlYNFpAXuHDUaDtPXkSp63U\r
+       fkSimzqyrCGtFoPOpq22ZCncaGa8l45EbRcoKxLVe+m/P8u7vDRtaLl70k3dCq0xAubz\r
+       04bRiRCGeMEpGg1L9EE9oXrmimfk701VOZgLL5MOpxhV2KIp4YS2rjhlhnXBb171I5nO\r
+       3+I1d/QtIV0P9Q4vtLU7H7VAunxbLsXBMoR8QnZTHjQTxr4mkkY46OtU/9riUru6wtWd\r
+       yQVnJVJuz2A6/w0bmdIQf9ZjLPgo4eWOCpIDVKOoUTOHypRCWaXAjKjErnmInKWrC0uV\r
+       MREQ==\r
+X-Gm-Message-State:\r
+ ALoCoQklYqT24ribAAUf36Jp+LDqW94PqLZVws/Nwh/RuxnZV/aajJbDqL0qW9KICKCKXSUSAVut\r
+X-Received: by 10.194.200.68 with SMTP id jq4mr50248664wjc.58.1425831519252;\r
+       Sun, 08 Mar 2015 09:18:39 -0700 (PDT)\r
+Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
+       [188.238.59.76]) by mx.google.com with ESMTPSA id\r
+       hw7sm20452121wjb.24.2015.03.08.09.18.37\r
+       (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+       Sun, 08 Mar 2015 09:18:38 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/2] cli: fix top level --help combined with other options\r
+Date: Sun,  8 Mar 2015 18:18:54 +0200\r
+Message-Id: <1425831535-15920-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Sun, 08 Mar 2015 16:18:45 -0000\r
+\r
+If the top level --help is combined with other options, help\r
+fails. For example:\r
+\r
+    $ notmuch --version --help\r
+\r
+    Sorry, --help is not a known command. There's not much I can do to help.\r
+\r
+Fix this by adjusting argc and argv appropriately. The help command\r
+ignores argv[0] anyway, so we don't have to set it to "help".\r
+---\r
+ notmuch.c | 8 +++++++-\r
+ 1 file changed, 7 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch.c b/notmuch.c\r
+index 0fac0997865e..1717e8b3683c 100644\r
+--- a/notmuch.c\r
++++ b/notmuch.c\r
+@@ -315,7 +315,13 @@ main (int argc, char *argv[])\r
+     }\r
\r
+     if (print_help) {\r
+-      ret = notmuch_help_command (NULL, argc - 1, &argv[1]);\r
++      /*\r
++       * Pass the first positional argument as argv[1] so the help\r
++       * command can give help for it. The help command ignores the\r
++       * argv[0] passed to it.\r
++       */\r
++      ret = notmuch_help_command (NULL, argc - opt_index + 1,\r
++                                  argv + opt_index - 1);\r
+       goto DONE;\r
+     }\r
\r
+-- \r
+2.1.4\r
+\r