mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-30 06:03:49 +08:00
23 lines
535 B
C++
23 lines
535 B
C++
// Print help message for the specified command.
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <cstring>
|
|
|
|
#include "common.h"
|
|
#include "print_help.h"
|
|
|
|
#define CMD_LEN 1024
|
|
|
|
#define HELP_ERR "Could not show help message\n"
|
|
|
|
void print_help(const char *c, int fd) {
|
|
char cmd[CMD_LEN];
|
|
int printed = snprintf(cmd, CMD_LEN, "fish -c '__fish_print_help %s >&%d'", c, fd);
|
|
|
|
if (printed < CMD_LEN && system(cmd) == -1) {
|
|
write_loop(2, HELP_ERR, std::strlen(HELP_ERR));
|
|
}
|
|
}
|