]> git.notmuchmail.org Git - notmuch/blob - test/corpus/23
c2b26dc8b0219857ba56c4b6867d09dcf046e478
[notmuch] / test / corpus / 23
1 From: "Lars Kellogg-Stedman" <lars@seas.harvard.edu>
2 To: notmuch@notmuchmail.org
3 Date: Tue, 17 Nov 2009 19:58:29 -0500
4 Subject: [notmuch] "notmuch help" outputs to stderr?
5 Message-ID: <20091118005829.GB25380@dottiness.seas.harvard.edu>
6
7 I'm just noticing that 'notmuch help ...' outputs to stderr, which
8 isn't terribly intuitive.  For example, the obvious invocation:
9
10   notmuch help | less
11
12 ...isn't terribly helpful.
13
14 I've attached a patch that lets usage() take a FILE * argument so that
15 you can output to stderr in response to usage errors, and stdout in
16 response to an explicit request.
17
18 -- 
19 Lars Kellogg-Stedman <lars at seas.harvard.edu>
20 Senior Technologist, Computing and Information Technology
21 Harvard University School of Engineering and Applied Sciences
22
23 -------------- next part --------------
24 diff --git a/notmuch.c b/notmuch.c
25 index c47e640..a35cb99 100644
26 --- a/notmuch.c
27 +++ b/notmuch.c
28 @@ -157,23 +157,23 @@ command_t commands[] = {
29  };
30  
31  static void
32 -usage (void)
33 +usage (FILE *out)
34  {
35      command_t *command;
36      unsigned int i;
37  
38 -    fprintf (stderr, "Usage: notmuch <command> [args...]\n");
39 -    fprintf (stderr, "\n");
40 -    fprintf (stderr, "Where <command> and [args...] are as follows:\n");
41 -    fprintf (stderr, "\n");
42 +    fprintf (out, "Usage: notmuch <command> [args...]\n");
43 +    fprintf (out, "\n");
44 +    fprintf (out, "Where <command> and [args...] are as follows:\n");
45 +    fprintf (out, "\n");
46  
47      for (i = 0; i < ARRAY_SIZE (commands); i++) {
48         command = &commands[i];
49  
50 -       fprintf (stderr, "\t%s\t%s\n\n", command->name, command->summary);
51 +       fprintf (out, "\t%s\t%s\n\n", command->name, command->summary);
52      }
53  
54 -    fprintf (stderr, "Use \"notmuch help <command>\" for more details on each command.\n\n");
55 +    fprintf (out, "Use \"notmuch help <command>\" for more details on each command.\n\n");
56  }
57  
58  static int
59 @@ -183,8 +183,8 @@ notmuch_help_command (unused (void *ctx), int argc, char *argv[])
60      unsigned int i;
61  
62      if (argc == 0) {
63 -       fprintf (stderr, "The notmuch mail system.\n\n");
64 -       usage ();
65 +       fprintf (stdout, "The notmuch mail system.\n\n");
66 +       usage (stdout);
67         return 0;
68      }
69  
70 -------------- next part --------------
71 A non-text attachment was scrubbed...
72 Name: not available
73 Type: application/pgp-signature
74 Size: 489 bytes
75 Desc: not available
76 URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20091117/03ed852d/attachment.pgp>
77