From: Mark Walters Date: Tue, 21 May 2013 19:21:17 +0000 (+0100) Subject: Re: [RFC PATCH 1/1] add --stderr option X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6e1291c21864a65845f56c3d3bb478690324f93a;p=notmuch-archives.git Re: [RFC PATCH 1/1] add --stderr option --- diff --git a/b2/2be9ea752258504866bfbd522c3910661271d1 b/b2/2be9ea752258504866bfbd522c3910661271d1 new file mode 100644 index 000000000..b84bcff8c --- /dev/null +++ b/b2/2be9ea752258504866bfbd522c3910661271d1 @@ -0,0 +1,156 @@ +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 146F4431FC0 + for ; Tue, 21 May 2013 12:21:38 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 nEuDQMgFhL2t for ; + Tue, 21 May 2013 12:21:30 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id DED19431FBF + for ; Tue, 21 May 2013 12:21:29 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1Ues7b-0006lY-LW; Tue, 21 May 2013 20:21:27 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1Ues7b-0002Cp-AM; Tue, 21 May 2013 20:21:19 +0100 +From: Mark Walters +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: [RFC PATCH 1/1] add --stderr option +In-Reply-To: <1369161750-12342-1-git-send-email-tomi.ollila@iki.fi> +References: <1369161750-12342-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 21 May 2013 20:21:17 +0100 +Message-ID: <87d2skuok2.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 1dc80c8599b12274e6725dc7cc7e41a8 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +Cc: tomi.ollila@iki.fi +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: Tue, 21 May 2013 19:21:38 -0000 + + +On Tue, 21 May 2013, Tomi Ollila wrote: +> --- +> +> Note quickly written untested code (but compiles!), just to show an idea... +> +> This implements (i hope) curl(1) --stderr option in notmuch(1): +> +> --stderr +> Redirect all writes to stderr to the specified file instead. If +> the file name is a plain '-', it is instead written to stdout. +> +> This would be useful in emacs interface. +> +> Please comment; I'll do help and manual page changes (and NEWS) if +> this is good idea :D + +I think this looks really nice. +1 for something like this. + +Mark + +> Tomi +> +> +> notmuch.c | 20 ++++++++++++++++++++ +> 1 file changed, 20 insertions(+) +> +> diff --git a/notmuch.c b/notmuch.c +> index f51a84f..3b8bd5d 100644 +> --- a/notmuch.c +> +++ b/notmuch.c +> @@ -21,6 +21,7 @@ +> */ +> +> #include "notmuch-client.h" +> +#include +> +> typedef int (*command_function_t) (notmuch_config_t *config, int argc, char *argv[]); +> +> @@ -259,6 +260,7 @@ main (int argc, char *argv[]) +> const char *command_name = NULL; +> command_t *command; +> char *config_file_name = NULL; +> + char *stderr_file = NULL; +> notmuch_config_t *config; +> notmuch_bool_t print_help=FALSE, print_version=FALSE; +> int opt_index; +> @@ -268,6 +270,7 @@ main (int argc, char *argv[]) +> { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 }, +> { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 }, +> { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 }, +> + { NOTMUCH_OPT_STRING, &stderr_file, "stderr", 'c', 0 }, +> { 0, 0, 0, 0, 0 } +> }; +> +> @@ -295,6 +298,23 @@ main (int argc, char *argv[]) +> return 0; +> } +> +> + if (stderr_file) { +> + if (strcmp (stderr_file, "-") == 0) +> + dup2 (STDOUT_FILENO, STDERR_FILENO); +> + else { +> + int fd = open (stderr_file, O_WRONLY|O_CREAT|O_APPEND, 0644); +> + if (fd < 0) { +> + fprintf (stderr, "Error: Cannot redirect stderr to '%s': %s\n", +> + stderr_file, strerror(errno)); +> + return 1; +> + } +> + if (fd != STDERR_FILENO) { +> + dup2 (fd, STDERR_FILENO); +> + close (fd); +> + } +> + } +> + } +> + +> if (opt_index < argc) +> command_name = argv[opt_index]; +> +> -- +> 1.8.1.4 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch