print_help: simplify function to always use stdout

It's only called in two places and always uses stdout.
This commit is contained in:
David Adam 2023-05-28 12:46:27 +08:00
parent ffb6168221
commit 3b55563769
4 changed files with 5 additions and 5 deletions

View file

@ -341,7 +341,7 @@ int main(int argc, char *argv[]) {
break;
}
case 'h': {
print_help("fish_indent", 1);
print_help("fish_indent");
exit(0);
}
case 'v': {

View file

@ -312,7 +312,7 @@ static bool parse_flags(int argc, char **argv, bool *continuous_mode, bool *verb
break;
}
case 'h': {
print_help("fish_key_reader", 1);
print_help("fish_key_reader");
exit(0);
}
case 'v': {

View file

@ -14,9 +14,9 @@
#define HELP_ERR "Could not show help message\n"
void print_help(const char *c, int fd) {
void print_help(const char *c) {
char cmd[CMD_LEN];
int printed = snprintf(cmd, CMD_LEN, "fish -c '__fish_print_help %s >&%d'", c, fd);
int printed = snprintf(cmd, CMD_LEN, "fish -c '__fish_print_help %s'", c);
if (printed < CMD_LEN && system(cmd) == -1) {
write_loop(2, HELP_ERR, std::strlen(HELP_ERR));

View file

@ -3,6 +3,6 @@
#define FISH_PRINT_HELP_H
/// Print help message for the specified command.
void print_help(const char *cmd, int fd);
void print_help(const char *cmd);
#endif