From 3f35280a364bd35293d3e5804eb2a659a7f174b1 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 23 Apr 2012 11:11:43 +0530 Subject: cli: implement a fn 'cli_err()' to send error messages to 'stderr' we were using 'cli_out()' to send all the possible msgs, which is not very friendly with scripts, because if one want to get only valid output with " 2>/error.log 1>/proper-info.log" Change-Id: I008ebcbd90935c41dbfc1bd2adeb094ed21116cb Signed-off-by: Amar Tumballi BUG: 815194 Reviewed-on: http://review.gluster.com/3208 Tested-by: Gluster Build System Reviewed-by: Kaushal M Reviewed-by: Vijay Bellur --- cli/src/cli.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'cli/src/cli.c') diff --git a/cli/src/cli.c b/cli/src/cli.c index 7a490fed2..6a5ecf698 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -450,10 +450,34 @@ cli_usage_out (const char *usage) if (!usage || usage[0] == '\0') return -1; - cli_out ("Usage: %s", usage); + cli_err ("Usage: %s", usage); return 0; } +int +_cli_err (const char *fmt, ...) +{ + struct cli_state *state = NULL; + va_list ap; + int ret = 0; + + state = global_state; + + va_start (ap, fmt); + +#ifdef HAVE_READLINE + if (state->rl_enabled && !state->rl_processing) + return cli_rl_err(state, fmt, ap); +#endif + + ret = vfprintf (stderr, fmt, ap); + fprintf (stderr, "\n"); + va_end (ap); + + return ret; +} + + int _cli_out (const char *fmt, ...) { -- cgit