diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index 788e4314c..066dcd352 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -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' diff --git a/src/builtin.cpp b/src/builtin.cpp index bd31ebe2d..da8bdeb18 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -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(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. diff --git a/src/builtin.h b/src/builtin.h index 88e01769a..0d7831c25 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -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")