diff --git a/doc_src/command.txt b/doc_src/command.txt index e4f5c2cf6..673522587 100644 --- a/doc_src/command.txt +++ b/doc_src/command.txt @@ -13,7 +13,7 @@ The following options are available: - `-a` or `--all` returns all the external commands that are found in `$PATH` in the order they are found. -- `-q` or `--quiet`, in conjunction with `-s`, silences the output and prints nothing, setting only the exit code. +- `-q` or `--quiet`, silences the output and prints nothing, setting only the exit code. Implies `--search`. - `-s` or `--search` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the `$PATH`. @@ -27,4 +27,4 @@ For basic compatibility with POSIX `command`, the `-v` flag is recognized as an `command -s ls` returns the path to the `ls` program. -`command -sq git; and command git log` runs `git log` only if `git` exists. +`command -q git; and command git log` runs `git log` only if `git` exists. diff --git a/src/builtin_command.cpp b/src/builtin_command.cpp index 1e038e68d..e8308bb76 100644 --- a/src/builtin_command.cpp +++ b/src/builtin_command.cpp @@ -87,7 +87,8 @@ int builtin_command(parser_t &parser, io_streams_t &streams, wchar_t **argv) { return STATUS_CMD_OK; } - if (!opts.find_path && !opts.all_paths) { + // Quiet implies find_path. + if (!opts.find_path && !opts.all_paths && !opts.quiet) { builtin_print_help(parser, streams, cmd, streams.out); return STATUS_INVALID_ARGS; } @@ -101,7 +102,7 @@ int builtin_command(parser_t &parser, io_streams_t &streams, wchar_t **argv) { if (!opts.quiet) streams.out.append_format(L"%ls\n", path.c_str()); ++found; } - } else { + } else { // Either find_path explicitly or just quiet. wcstring path; if (path_get_path(command_name, &path, parser.vars())) { if (!opts.quiet) streams.out.append_format(L"%ls\n", path.c_str());