builtin builtin: Print help if run without an action to do

Fixes #9942
This commit is contained in:
Fabian Boehm 2023-08-09 17:23:33 +02:00
parent 0844247b43
commit 27a11ef7fe
2 changed files with 13 additions and 0 deletions

View File

@ -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) {

View File

@ -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