Show an error when "builtin -h" fails to find a man page
Prior to this commit "builtin -h" would silently fail when no documentation is installed. This happens when running fish without installing it, or when the docs are not installed. See #7824
This commit is contained in:
parent
582675c96a
commit
f9e131aa93
@ -10,7 +10,7 @@ function __fish_print_help --description "Print help message for the specified f
|
||||
|
||||
# Do nothing if the file does not exist
|
||||
if not test -e "$__fish_data_dir/man/man1/$item.1" -o -e "$__fish_data_dir/man/man1/$item.1.gz"
|
||||
return
|
||||
return 2
|
||||
end
|
||||
|
||||
# Render help output, save output into the variable 'help'
|
||||
|
@ -155,7 +155,6 @@ int parse_help_only_cmd_opts(struct help_only_cmd_opts_t &opts, int *optind, int
|
||||
/// Process and print help for the specified builtin or function.
|
||||
void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wchar_t *name,
|
||||
wcstring *error_message) {
|
||||
UNUSED(streams);
|
||||
// This won't ever work if no_exec is set.
|
||||
if (no_exec()) return;
|
||||
const wcstring name_esc = escape_string(name, ESCAPE_ALL);
|
||||
@ -166,8 +165,10 @@ void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wch
|
||||
// If it's an error, redirect the output of __fish_print_help to stderr
|
||||
ios.push_back(std::make_shared<io_fd_t>(STDOUT_FILENO, STDERR_FILENO));
|
||||
}
|
||||
parser.eval(cmd, ios);
|
||||
// ignore the exit status of __fish_print_help
|
||||
auto res = parser.eval(cmd, ios);
|
||||
if (res.status.exit_code() == 2) {
|
||||
streams.err.append_format(BUILTIN_ERR_MISSING_HELP, name_esc.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform error reporting for encounter with unknown option.
|
||||
|
@ -36,6 +36,10 @@ enum { COMMAND_NOT_BUILTIN, BUILTIN_REGULAR, BUILTIN_FUNCTION };
|
||||
/// Error message on missing argument.
|
||||
#define BUILTIN_ERR_MISSING _(L"%ls: Expected argument for option %ls\n")
|
||||
|
||||
/// Error message on missing man page.
|
||||
#define BUILTIN_ERR_MISSING_HELP \
|
||||
_(L"fish: Missing man page for '%ls'. Did you install the documentation?\n")
|
||||
|
||||
/// Error message on invalid combination of options.
|
||||
#define BUILTIN_ERR_COMBO _(L"%ls: Invalid combination of options\n")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user