Commit f39c4518 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Fix a problem generating an error while using flag -h

parent 88377749
......@@ -307,7 +307,15 @@ static void blc_program_interpret_parameters(int *argc, char **argv[]){
if ((*argc)==0){//There is no more argument to interpret
if (blc_program_parameters[i].required_nb){
if (isatty(STDIN_FILENO)) fprintf(stderr, "%s: %s? ", blc_program_parameters[i].help, blc_program_parameters[i].name);
SYSTEM_ERROR_CHECK(parameter_read=getline(&tmp_parameter, &linecap, stdin), -1, "Reading input for parameter");
parameter_read=getline(&tmp_parameter, &linecap, stdin);
if (parameter_read==-1){
if (errno==ENOTTY) {
color_eprintf(BLC_RED, "\nQuitting '%s': The standard input is not available. You probably have a program on an input pipe which has crashed\n", blc_program_name);
exit(1);
}
else EXIT_ON_SYSTEM_ERROR("Reading input for parameter");
}
tmp_parameter[parameter_read-1]=0;//Remove the last return;
(*blc_program_parameters[i].string_pt)=tmp_parameter;
linecap=0;
......@@ -480,14 +488,13 @@ void blc_program_init(int *argc, char ***argv, void (*exit_cb)(void))
blc_program_add_option(&help, 'h', "help", 0, "display this help", NULL);
blc_program_parse_args_and_print_title(argc, argv);
blc_program_check_full_parsing(*argc, *argv);
if (help){
blc_program_args_display_help();
exit(EXIT_SUCCESS);
}
blc_program_check_full_parsing(*argc, *argv);
atexit(blc_quit);
if (exit_cb) atexit(exit_cb); //This will be called first
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment