From 96ee1ea086160c69c7dfe0c4d2c4a7201ec3b0d1 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 1 Nov 2023 17:04:43 +0000 Subject: [PATCH] gio-tool: Print help output to stdout when --help is passed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the help output is explicitly requested by the user, it’s conventional for it to be printed to stdout rather than stderr. Signed-off-by: Philip Withnall --- gio/gio-tool.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gio/gio-tool.c b/gio/gio-tool.c index 95f000c1d..6315b48bf 100644 --- a/gio/gio-tool.c +++ b/gio/gio-tool.c @@ -249,7 +249,7 @@ static const struct }; static void -usage (void) +usage (gboolean is_error) { GString *out = NULL; size_t name_width = 0; @@ -274,7 +274,10 @@ usage (void) g_string_append_c (out, '\n'); g_string_append_printf (out, _("Use %s to get detailed help.\n"), "“gio help COMMAND”"); - g_printerr ("%s", out->str); + if (is_error) + g_printerr ("%s", out->str); + else + g_print ("%s", out->str); g_string_free (out, TRUE); } @@ -306,7 +309,7 @@ main (int argc, char **argv) if (argc < 2) { - usage (); + usage (TRUE); return 1; } @@ -319,7 +322,7 @@ main (int argc, char **argv) { if (argc == 1) { - usage (); + usage (FALSE); return 0; } else @@ -330,7 +333,7 @@ main (int argc, char **argv) } else if (g_str_equal (command, "--help")) { - usage (); + usage (FALSE); return 0; } else if (g_str_equal (command, "--version")) @@ -347,7 +350,7 @@ main (int argc, char **argv) } /* Unknown subcommand. */ - usage (); + usage (TRUE); return 1; }