From cb9e99bcc27a7653b95e39d9b5bc03cd06a4486d Mon Sep 17 00:00:00 2001 From: Jose Carlos Leiva Date: Wed, 29 Jul 2026 01:06:10 +0200 Subject: [PATCH] gio: Handle "gio help help" correctly Avoid triggering an assertion when requesting help for the help subcommand. Instead, report that help cannot be displayed for the help subcommand and exit with an error. Fixes: #4007 --- gio/gio-tool.c | 6 ++++++ gio/tests/gio-tool.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/gio/gio-tool.c b/gio/gio-tool.c index 6315b48bf..a0370485e 100644 --- a/gio/gio-tool.c +++ b/gio/gio-tool.c @@ -344,6 +344,12 @@ main (int argc, char **argv) { if (g_str_equal (command, gio_subcommands[i].name)) { + if (g_str_equal (command, "help")) + { + usage (FALSE); + return 0; + } + g_assert (gio_subcommands[i].handle_func != NULL); return gio_subcommands[i].handle_func (argc, argv, do_help); } diff --git a/gio/tests/gio-tool.py b/gio/tests/gio-tool.py index 11997c937..eaa27c892 100644 --- a/gio/tests/gio-tool.py +++ b/gio/tests/gio-tool.py @@ -56,10 +56,14 @@ class TestGioTool(testprogramrunner.TestProgramRunner): """Test the --help argument and help subcommand.""" result = self.runGio("--help") result2 = self.runGio("help") + result3 = self.runGio("help", "help") self.assertEqual(result.out, result2.out) self.assertEqual(result.err, result2.err) + self.assertEqual(result2.out, result3.out) + self.assertEqual(result2.err, result3.err) + self.assertIn("Usage:\n gio COMMAND", result.out) self.assertIn("List the contents of locations", result.out)