fish-shell/src/print_help.cpp
David Adam 9225b16d12 add (or restore) config.h to all files
The autoconf-generated config.h contains a number of directives which
may alter the behaviour of system headers on certain platforms. Always
include it in every C++ file as the first include.

Closes #2993.
2016-05-18 22:30:21 +00:00

25 lines
559 B
C++

// Print help message for the specified command.
#include "config.h" // IWYU pragma: keep
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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) {
if ((system(cmd) == -1)) {
write_loop(2, HELP_ERR, strlen(HELP_ERR));
}
}
}