}
} 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);
}
* 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) {
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;
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);
return ERROR_COMMAND_ARGUMENT_INVALID; \
} \
char *end; \
+ errno = 0; \
*ul = func(str, &end, 0); \
if (*end) { \
LOG_ERROR("Invalid command argument"); \