git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC][PATCH] Print the usage string on stdout instead of stderr.

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
May 17, 2010, 13:30 UTC
Message-ID
<4BF14508.8040307@drmicha.warpmail.net>
In-Reply-To
<87vdamu2es.fsf@thor.thematica.it>
Giuseppe Scrivano venit, vidit, dixit 17.05.2010 14:40:
Show 15 quoted lines
> Michael J Gruber <git@drmicha.warpmail.net> writes:
> 
>> More importantly, callers expect error messages on stderr, such as usage
>> with wrong arguments. I don't think scripts would call commands with
>> '-h', and if they do they do so on purpose and can parse stderr, knowing
>> there is no stdout in this case.
> 
> It looks like a workaround to me.  Anyway, if -h is left unchanged then,
> I think, --help should be adjusted as well when it doesn't use an
> external pager.
> 
> These two commands behave differently:
> 
> git status --help 2>/dev/null | cat -
> git status -h 2>/dev/null | cat -

They also do two very different things. The first one displays the man page, the second the usage string.

> IMO, what should be changed is -h to be uniform with --help, as the it
> is the expected output, not an error.
That is not what your patch does.

I'm not opposed to having -h output on stdout. I'm opposed to having usage error messages on stdout. Currently, both are on stderr, which is no problem (we're not bound by GNU rules here).

Your patch puts both on stdout, and that is a problem, not only for several test which could be adjusted, but also for scripters.

A patch which *really* only changes '-h' to use stdout would certainly not be objected. Actually, most calling sites are probably the "error case" so that you only need to make sure that the "-h" path get's to use a different output file descriptor.

Cheers, Michael

Previous: Giuseppe ScrivanoNext: Giuseppe Scrivano
Message 9 of 14 in “Print the usage string on stdout instead of stderr.”
  1. Giuseppe ScrivanoMay 17, 2010
  2. Michael J GruberMay 17, 2010
  3. Miles BaderMay 17, 2010
  4. Michael J GruberMay 17, 2010
  5. Miles BaderMay 17, 2010
  6. Giuseppe ScrivanoMay 17, 2010
  7. Tay Ray ChuanMay 17, 2010
  8. Giuseppe ScrivanoMay 17, 2010
  9. Michael J GruberMay 17, 2010
  10. Giuseppe ScrivanoMay 17, 2010
  11. Michael J GruberMay 18, 2010
  12. Giuseppe ScrivanoMay 24, 2010
  13. Michael J GruberMay 25, 2010
  14. Print the usage string on stdout instead of stderr.Giuseppe Scrivano, May 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.