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