fish-shell/print_help.cpp
ridiculousfish be33d3f2a4 Revert "Merge pull request #1317 from pullreq/cpp"
This reverts commit 74135c0600, reversing
changes made to 6d749789ce.

See discussion in #1317
2014-02-28 02:16:48 -08:00

35 lines
625 B
C++

/** \file print_help.c
Print help message for the specified command
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "print_help.h"
#define CMD_LEN 1024
#define HELP_ERR "Could not show help message\n"
/* defined in common.h */
ssize_t write_loop(int fd, const char *buff, size_t count);
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));
}
}
}