diff options
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/command.c | 36 | ||||
-rw-r--r-- | src/helper/startup.tcl | 6 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index 9d19cff..a0aa9e8 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -121,7 +121,7 @@ static int command_retval_set(Jim_Interp *interp, int retval) if (return_retval != NULL) *return_retval = retval; - return (retval == ERROR_OK) ? JIM_OK : JIM_ERR; + return (retval == ERROR_OK) ? JIM_OK : retval; } extern struct command_context *global_cmd_ctx; @@ -659,24 +659,7 @@ int command_run_line(struct command_context *context, char *line) } Jim_DeleteAssocData(interp, "context"); } - if (retcode == JIM_ERR) { - if (retval == ERROR_COMMAND_CLOSE_CONNECTION) { - /* Shutdown request is not an error */ - return ERROR_OK; - } else { - /* We do not print the connection closed error message */ - Jim_MakeErrorMessage(interp); - LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL)); - } - if (retval == ERROR_OK) { - /* It wasn't a low level OpenOCD command that failed */ - return ERROR_FAIL; - } - return retval; - } else if (retcode == JIM_EXIT) { - /* ignore. - * exit(Jim_GetExitCode(interp)); */ - } else { + if (retcode == JIM_OK) { const char *result; int reslen; @@ -696,7 +679,22 @@ int command_run_line(struct command_context *context, char *line) LOG_USER_N("\n"); } retval = ERROR_OK; + } else if (retcode == JIM_EXIT) { + /* ignore. + * exit(Jim_GetExitCode(interp)); */ + } else if (retcode == ERROR_COMMAND_CLOSE_CONNECTION) { + return retcode; + } else { + Jim_MakeErrorMessage(interp); + LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL)); + + if (retval == ERROR_OK) { + /* It wasn't a low level OpenOCD command that failed */ + return ERROR_FAIL; + } + return retval; } + return retval; } diff --git a/src/helper/startup.tcl b/src/helper/startup.tcl index 926d26b..4ca2cab 100644 --- a/src/helper/startup.tcl +++ b/src/helper/startup.tcl @@ -16,10 +16,12 @@ proc exit {} { proc ocd_bouncer {name args} { set cmd [format "ocd_%s" $name] set type [eval ocd_command type $cmd $args] + set errcode error if {$type == "native"} { return [eval $cmd $args] } else {if {$type == "simple"} { - if {[catch {eval $cmd $args}] == 0} { + set errcode [catch {eval $cmd $args}] + if {$errcode == 0} { return "" } else { # 'classic' commands output error message as part of progress output @@ -32,7 +34,7 @@ proc ocd_bouncer {name args} { } else { set errmsg [format "invalid subcommand \"%s\"" $args] }}} - return -code error $errmsg + return -code $errcode $errmsg } # Try flipping / and \ to find file if the filename does not |