helper/command: print the command output in case of error

In case of error, a command should use command_print() to report
the error message, so it get printed only on the session that run
the command itself, and the message can be intercepted with the
tcl command catch if it has to be handled differently.
Current code drops the command output when the command returns
error, claiming that it's the command that *should* have printed
it already. This is true only if we *abuse* of the LOG functions,
but accepting the side issue of having the LOG printed in every
session and being unable to catch{} the error message.

Since we have switched to command_print(), change the code to
propagate the command output also in case of error.

Change-Id: I95de424a65e63702bdb3b2277749a0ac6aaaa503
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5178
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
bscan_optimization
Antonio Borneo 2019-05-15 16:27:26 +02:00 committed by Tomas Vanek
parent e162200ab2
commit 2b78f65aa9
1 changed files with 6 additions and 8 deletions

View File

@ -623,15 +623,13 @@ static int run_command(struct command_context *context,
}
} else if (retval == ERROR_COMMAND_CLOSE_CONNECTION) {
/* just fall through for a shutdown request */
} else if (retval != ERROR_OK) {
/* we do not print out an error message because the command *should*
* have printed out an error
*/
} else {
if (retval != ERROR_OK) {
char *full_name = command_name(c, ' ');
LOG_DEBUG("Command '%s' failed with error code %d",
full_name ? full_name : c->name, retval);
free(full_name);
} else {
}
/* Use the command output as the Tcl result */
Jim_SetResult(context->interp, cmd.output);
}