2016-05-02 21:41:17 -07:00
|
|
|
// Print help message for the specified command.
|
2016-05-18 22:30:21 +00:00
|
|
|
#include "config.h" // IWYU pragma: keep
|
|
|
|
|
2019-10-13 15:50:48 -07:00
|
|
|
#include "print_help.h"
|
|
|
|
|
2006-11-18 02:24:38 +10:00
|
|
|
#include <stdio.h>
|
2016-05-02 21:41:17 -07:00
|
|
|
#include <stdlib.h>
|
2019-10-13 15:50:48 -07:00
|
|
|
|
2019-03-12 15:07:07 -07:00
|
|
|
#include <cstring>
|
2006-11-18 02:24:38 +10:00
|
|
|
|
2016-05-02 21:41:17 -07:00
|
|
|
#include "common.h"
|
2006-11-18 02:24:38 +10:00
|
|
|
|
2022-09-20 11:58:37 -07:00
|
|
|
#define CMD_LEN 1024
|
|
|
|
|
|
|
|
#define HELP_ERR "Could not show help message\n"
|
2009-02-23 06:28:52 +10:00
|
|
|
|
2016-05-02 21:41:17 -07:00
|
|
|
void print_help(const char *c, int fd) {
|
|
|
|
char cmd[CMD_LEN];
|
2012-11-18 16:30:30 -08:00
|
|
|
int printed = snprintf(cmd, CMD_LEN, "fish -c '__fish_print_help %s >&%d'", c, fd);
|
2012-11-18 11:23:22 +01:00
|
|
|
|
2016-10-22 11:21:13 -07:00
|
|
|
if (printed < CMD_LEN && system(cmd) == -1) {
|
2022-09-20 11:58:37 -07:00
|
|
|
write_loop(2, HELP_ERR, std::strlen(HELP_ERR));
|
2012-11-18 16:30:30 -08:00
|
|
|
}
|
2006-11-18 02:24:38 +10:00
|
|
|
}
|