mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 20:31:19 -03:00
Initial C++ conversion
This commit is contained in:
34
print_help.cpp
Normal file
34
print_help.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
/** \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, char *buff, size_t count);
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
if( printed < CMD_LEN )
|
||||
{
|
||||
if( (system( cmd ) == -1) )
|
||||
{
|
||||
write_loop(2, HELP_ERR, strlen(HELP_ERR));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user