From 27a11ef7fe3b5fa7896da8f3813da2fffed702dd Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 9 Aug 2023 17:23:33 +0200 Subject: [PATCH] builtin builtin: Print help if run without an action to do Fixes #9942 --- fish-rust/src/builtins/builtin.rs | 8 ++++++++ tests/checks/builtinbuiltin.fish | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/fish-rust/src/builtins/builtin.rs b/fish-rust/src/builtins/builtin.rs index 064cc0264..b78704df4 100644 --- a/fish-rust/src/builtins/builtin.rs +++ b/fish-rust/src/builtins/builtin.rs @@ -56,6 +56,14 @@ pub fn r#builtin( return STATUS_INVALID_ARGS; } + // If we don't have either, we print our help. + // This is also what e.g. command and time, + // the other decorator/builtins do. + if !opts.query && !opts.list_names { + builtin_print_help(parser, streams, cmd); + return STATUS_INVALID_ARGS; + } + if opts.query { let optind = w.woptind; for arg in argv.iter().take(argc).skip(optind) { diff --git a/tests/checks/builtinbuiltin.fish b/tests/checks/builtinbuiltin.fish index 618f5cd55..7c8e7193d 100644 --- a/tests/checks/builtinbuiltin.fish +++ b/tests/checks/builtinbuiltin.fish @@ -9,4 +9,9 @@ builtin -nq string #CHECKERR: builtin: invalid option combination, --query and --names are mutually exclusive echo $status #CHECK: 2 + +builtin -- -q &| grep -q "builtin - run a builtin command\|fish: builtin: missing man page" +echo $status +#CHECK: 0 + exit 0