X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Fcommand.c;h=d969933e2dba0bc9c8f8c554c83def7c97c9d20b;hp=e8ade3f7039597edd810037e52e5e42d7c3037e0;hb=31a3324b68827ed7fd6c545d04373b63bd828d6b;hpb=92b582ed62ca4f21f469d71637befb0880555b7a diff --git a/src/helper/command.c b/src/helper/command.c index e8ade3f703..d969933e2d 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -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 - */ - 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 { + 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); + } /* Use the command output as the Tcl result */ Jim_SetResult(context->interp, cmd.output); } @@ -654,9 +652,11 @@ int command_run_line(struct command_context *context, char *line) * happen when the Jim Tcl interpreter is provided by eCos for * instance. */ + struct target *saved_target_override = context->current_target_override; context->current_target_override = NULL; Jim_Interp *interp = context->interp; + struct command_context *old_context = Jim_GetAssocData(interp, "context"); Jim_DeleteAssocData(interp, "context"); retcode = Jim_SetAssocData(interp, "context", NULL, context); if (retcode == JIM_OK) { @@ -669,7 +669,11 @@ int command_run_line(struct command_context *context, char *line) Jim_DeleteAssocData(interp, "retval"); } Jim_DeleteAssocData(interp, "context"); + int inner_retcode = Jim_SetAssocData(interp, "context", NULL, old_context); + if (retcode == JIM_OK) + retcode = inner_retcode; } + context->current_target_override = saved_target_override; if (retcode == JIM_OK) { const char *result; int reslen; @@ -1030,12 +1034,6 @@ static int run_usage(Jim_Interp *interp, int argc_valid, int argc, Jim_Obj * con static int command_unknown(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { const char *cmd_name = Jim_GetString(argv[0], NULL); - if (strcmp(cmd_name, "unknown") == 0) { - if (argc == 1) - return JIM_OK; - argc--; - argv++; - } script_debug(interp, cmd_name, argc, argv); struct command_context *cmd_ctx = current_command_context(interp); @@ -1396,6 +1394,7 @@ void process_jim_events(struct command_context *cmd_ctx) return ERROR_COMMAND_ARGUMENT_INVALID; \ } \ char *end; \ + errno = 0; \ *ul = func(str, &end, 0); \ if (*end) { \ LOG_ERROR("Invalid command argument"); \