mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-04 01:25:25 +08:00
builtin_print_help to take its error argument by reference
This fixes a confusing use of pointers.
This commit is contained in:
parent
5c216e3d8c
commit
30c708e8a5
@ -144,14 +144,14 @@ 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) {
|
||||
const wcstring &error_message) {
|
||||
// This won't ever work if no_exec is set.
|
||||
if (no_exec()) return;
|
||||
const wcstring name_esc = escape_string(name);
|
||||
wcstring cmd = format_string(L"__fish_print_help %ls ", name_esc.c_str());
|
||||
io_chain_t ios;
|
||||
if (error_message) {
|
||||
cmd.append(escape_string(*error_message));
|
||||
if (!error_message.empty()) {
|
||||
cmd.append(escape_string(error_message));
|
||||
// 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));
|
||||
}
|
||||
@ -268,7 +268,7 @@ static maybe_t<int> builtin_break_continue(parser_t &parser, io_streams_t &strea
|
||||
|
||||
if (argc != 1) {
|
||||
wcstring error_message = format_string(BUILTIN_ERR_UNKNOWN, argv[0], argv[1]);
|
||||
builtin_print_help(parser, streams, argv[0], &error_message);
|
||||
builtin_print_help(parser, streams, argv[0], error_message);
|
||||
return STATUS_INVALID_ARGS;
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ static maybe_t<int> builtin_break_continue(parser_t &parser, io_streams_t &strea
|
||||
}
|
||||
if (!has_loop) {
|
||||
wcstring error_message = format_string(_(L"%ls: Not inside of loop\n"), argv[0]);
|
||||
builtin_print_help(parser, streams, argv[0], &error_message);
|
||||
builtin_print_help(parser, streams, argv[0], error_message);
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ const wchar_t *builtin_get_desc(const wcstring &name);
|
||||
wcstring builtin_help_get(parser_t &parser, const wchar_t *cmd);
|
||||
|
||||
void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wchar_t *name,
|
||||
wcstring *error_message = nullptr);
|
||||
const wcstring &error_message = {});
|
||||
int builtin_count_args(const wchar_t *const *argv);
|
||||
|
||||
void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar_t *cmd,
|
||||
|
@ -27,7 +27,7 @@ static int send_to_bg(parser_t &parser, io_streams_t &streams, job_t *j) {
|
||||
wcstring error_message = format_string(
|
||||
_(L"%ls: Can't put job %d, '%ls' to background because it is not under job control\n"),
|
||||
L"bg", j->job_id(), j->command_wcstr());
|
||||
builtin_print_help(parser, streams, L"bg", &error_message);
|
||||
builtin_print_help(parser, streams, L"bg", error_message);
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user