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