2006-11-18 00:24:38 +08:00
|
|
|
|
|
|
|
/** \file print_help.c
|
2012-11-18 18:23:22 +08:00
|
|
|
Print help message for the specified command
|
2006-11-18 00:24:38 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2009-02-23 04:28:52 +08:00
|
|
|
#include <string.h>
|
2006-11-18 00:24:38 +08:00
|
|
|
|
|
|
|
#include "print_help.h"
|
|
|
|
|
|
|
|
#define CMD_LEN 1024
|
|
|
|
|
2009-02-23 04:28:52 +08:00
|
|
|
#define HELP_ERR "Could not show help message\n"
|
|
|
|
|
2009-12-02 00:07:22 +08:00
|
|
|
/* defined in common.h */
|
2012-01-14 19:41:50 +08:00
|
|
|
ssize_t write_loop(int fd, const char *buff, size_t count);
|
2009-12-02 00:07:22 +08:00
|
|
|
|
|
|
|
|
2012-11-19 08:30:30 +08:00
|
|
|
void print_help(const char *c, int fd)
|
2006-11-18 00:24:38 +08:00
|
|
|
{
|
2012-11-19 08:30:30 +08:00
|
|
|
char cmd[ CMD_LEN];
|
|
|
|
int printed = snprintf(cmd, CMD_LEN, "fish -c '__fish_print_help %s >&%d'", c, fd);
|
2012-11-18 18:23:22 +08:00
|
|
|
|
2012-11-19 08:30:30 +08:00
|
|
|
if (printed < CMD_LEN)
|
2012-11-18 18:23:22 +08:00
|
|
|
{
|
2012-11-19 08:30:30 +08:00
|
|
|
if ((system(cmd) == -1))
|
|
|
|
{
|
|
|
|
write_loop(2, HELP_ERR, strlen(HELP_ERR));
|
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
2012-11-19 08:30:30 +08:00
|
|
|
}
|
2012-11-18 18:23:22 +08:00
|
|
|
|
2006-11-18 00:24:38 +08:00
|
|
|
}
|