From d81395b672a778c3cd7923cb5d365b7b50392a0f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 4 Mar 2024 21:21:16 +1100 Subject: [PATCH] [common] option: send all output to stderr --- common/src/option.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/common/src/option.c b/common/src/option.c index e32935dd..ee0e3268 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -704,23 +704,24 @@ bool option_validate(void) if (invalid) { - printf("\nInvalid value provided to the option: %s:%s\n", o->module, o->name); + fprintf(stderr, "\nInvalid value provided to the option: %s:%s\n", + o->module, o->name); if (error) - printf("\n Error: %s\n", error); + fprintf(stderr, "\n Error: %s\n", error); if (o->getValues) { StringList values = o->getValues(o); - printf("\nValid values are:\n\n"); + fprintf(stderr, "\nValid values are:\n\n"); for(unsigned int v = 0; v < stringlist_count(values); ++v) - printf(" * %s\n", stringlist_at(values, v)); + fprintf(stderr, " * %s\n", stringlist_at(values, v)); stringlist_free(&values); } if (o->printHelp) { - printf("\n"); + fprintf(stderr, "\n"); o->printHelp(); } @@ -729,34 +730,33 @@ bool option_validate(void) } if (!ok) - printf("\n"); + fprintf(stderr, "\n"); return ok; } void option_print_hrule(char * headerLine, int maxLen, char ruleChar) { - printf(" +%c", ruleChar); + fprintf(stderr, " +%c", ruleChar); for (int i = 0; i < maxLen; i++) { if(i < strlen(headerLine)) { if (headerLine[i] == '|') { - putc('+', stdout); + putc('+', stderr); continue; } } - putc(ruleChar, stdout); + putc(ruleChar, stderr); } - printf("%c+\n", ruleChar); + fprintf(stderr, "%c+\n", ruleChar); } void option_print(void) { - printf( - "The following is a complete list of options accepted by this application\n\n" - ); + fprintf(stderr, "The following is a complete list of options accepted by this " + "application\n\n"); for(int g = 0; g < state.gCount; ++g) { @@ -850,7 +850,7 @@ void option_print(void) } char * line = stringlist_at(lines, i); - printf(" | %-*s |\n", maxLen, line); + fprintf(stderr, " | %-*s |\n", maxLen, line); if (i == 0) { @@ -866,7 +866,7 @@ void option_print(void) stringlist_free(&lines); - printf("\n"); + fprintf(stderr, "\n"); } }