From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 636EC431FD0 for ; Wed, 28 Dec 2011 18:23:38 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 Ba9AXy0BMEng for ; Wed, 28 Dec 2011 18:23:36 -0800 (PST) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id E816C431FB6 for ; Wed, 28 Dec 2011 18:23:35 -0800 (PST) X-AuditID: 12074422-b7fd66d0000008f9-4a-4efbcf273d3f Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id 1B.C7.02297.72FCBFE4; Wed, 28 Dec 2011 21:23:35 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id pBT2NYrV000797; Wed, 28 Dec 2011 21:23:34 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pBT2NW4o024564 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 28 Dec 2011 21:23:33 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rg5fH-0003Dq-Ak; Wed, 28 Dec 2011 21:24:19 -0500 Date: Wed, 28 Dec 2011 21:24:19 -0500 From: Austin Clements To: David Bremner Subject: Re: have "notmuch help" call man? Message-ID: <20111229022419.GI30150@mit.edu> References: <87zkescxp5.fsf@zancas.localnet> <87iplbyj0w.fsf@zancas.localnet> <87ehvxtgoi.fsf@zancas.localnet> <87k45pqkaz.fsf@servo.finestructure.net> <8739c6yhp0.fsf@zancas.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8739c6yhp0.fsf@zancas.localnet> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42IR4hRV1lU//9vPYOtdQYsbrd2MFnv2eVlc vzmT2YHZ4+5pLo9nq24xe2w59J45gDmKyyYlNSezLLVI3y6BK2Pxj43MBXdFK5Zt+MLYwPhI oIuRk0NCwETi5q1zrBC2mMSFe+vZuhi5OIQE9jFKPF45iRHC2cAoMXn+RFYI5ySTRMfS/+wQ zhJGiaPLDjKD9LMIqEr8W/OGEcRmE9CQ2LZ/OZgtAhS/um0yG4jNLJAucXn7DjBbWEBL4uvL P2C7eQV0JHa/eMwCMfQAo8T21zuYIBKCEidnPmGBaNaSuPHvJVCcA8iWllj+jwMkzCmgK7Hs fjs7iC0qoCIx5eQ2tgmMQrOQdM9C0j0LoXsBI/MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXVO9 3MwSvdSU0k2MoFBnd1HawfjzoNIhRgEORiUeXi/D335CrIllxZW5hxglOZiURHkrzgCF+JLy UyozEosz4otKc1KLDzFKcDArifDW7gbK8aYkVlalFuXDpKQ5WJTEedW13vkJCaQnlqRmp6YW pBbBZGU4OJQkeHPPATUKFqWmp1akZeaUIKSZODhBhvMADe8CqeEtLkjMLc5Mh8ifYlSUEudN AEkIgCQySvPgemGp6BWjONArwrxxIFU8wDQG1/0KaDAT0OBz536BDC5JREhJNTA2nuefsklA Mbpgp1ZiuN+y+vLY6kXGNou3ZPdz+71jT3t+64l3PGes+g/DY02bYw5mOvxq4D1966OoS82r N8k7SvJ3FZ88lTv1rKQtB//68pM7a3dyCWWVBN9SnFO1vsA/lUH3Q4++daSI+Yvl3+OMJ7zg Cnn/uutj0am9fOzX4l0XqnDICyqxFGckGmoxFxUnAgD56yGjIAMAAA== Cc: Notmuch Mail 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: Thu, 29 Dec 2011 02:23:38 -0000 Quoth David Bremner on Dec 26 at 8:35 pm: > The following changes since commit d61cef374b3234c2f1327fa74b612b40c196a605: > > show: Rewrite show_message_body to use the MIME tree interface. (2011-12-25 22:23:15 -0400) > > are available in the git repository at: > git://pivot.cs.unb.ca/notmuch split-man > > HEAD is at 8eaee754e48dc630d83e2f7369bdadde0f34af84 Some comments on "notmuch: replace built-in help with exec of man" > @@ -534,38 +126,20 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[]) > for (i = 0; i < ARRAY_SIZE (commands); i++) { > command = &commands[i]; > > - if (strcmp (argv[0], command->name) == 0) { > - printf ("Help for \"notmuch %s\":\n\n", argv[0]); > - if (command->arguments) > - printf ("%s %s\n\n\t%s\n\n%s\n\n", > - command->name, command->arguments, > - command->summary, command->documentation); > - else > - printf ("%s\t%s\n\n%s\n\n", command->name, > - command->summary, command->documentation); > - return 0; > + if (strncmp (argv[0], command->name, strlen (argv[0])) == 0) { Shouldn't this be strcmp? > + char *page = malloc (strlen (argv[0]) + strlen ("notmuch-") + 1); > + strcpy (page, "notmuch-"); > + strcat (page, command->name); This is fine, but could be cleaner with talloc: char *page = talloc_asprintf (ctx, "notmuch-%s", command->name); > + > + execlp ("man", "man", page, (char *) NULL); > + /* NOTREACHED */ This certainly *can* be reached if the exec fails. You should print a helpful error message and exit, maybe something like fprintf (stderr, "failed to exec man: %s\n", strerror (errno)); exit (1); > } > } > > - if (strcmp (argv[0], "search-terms") == 0) { > - printf ("Help for <%s>\n\n", argv[0]); > - for (i = 0; i < ARRAY_SIZE (commands); i++) { > - command = &commands[i]; > - > - if (command->arguments && > - strstr (command->arguments, "search-terms")) > - { > - printf ("\t%s\t%s\n", > - command->name, command->arguments); > - } > - } > - printf ("\n"); > - printf (search_terms_help); > - return 0; > - } else if (strcmp (argv[0], "hooks") == 0) { > - printf ("Help for <%s>\n\n", argv[0]); > - printf (hooks_help); > - return 0; > + if (strncmp (argv[0], "search-terms", strlen (argv[0])) == 0) { > + execlp ("man", "man", "notmuch-search-terms", (char *) NULL); > + } else if (strncmp (argv[0], "hooks", strlen (argv[0])) == 0) { > + execlp ("man", "man", "notmuch-hooks", (char *) NULL); Same comments about strncmp and exec failing for the above four lines. It might make sense to merge all of the exec calls in to one to centralize the error handling. > } > > fprintf (stderr,