fix error output a bit: do not repeat output printed during execution in case of...
[openocd.git] / src / helper / command.c
index 5ac57a1e2ff47083b7544049a7486870a11af019..7ce7c2245d94768065f4d63470a5f932ef34cdc5 100644 (file)
@@ -2,6 +2,9 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                      *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   part of this file is taken from libcli (libcli.sourceforge.net)       *
  *   Copyright (C) David Parrish (david@dparrish.com)                      *
  *                                                                         *
@@ -31,6 +34,7 @@
 
 #include "log.h"
 #include "time_support.h"
+#include "jim-eventloop.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -115,7 +119,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        log_remove_callback(tcl_output, tclOutput);
 
        /* We dump output into this local variable */
-       Jim_SetVariableStr(interp, "ocd_output", tclOutput);
+       Jim_SetResult(interp, tclOutput);
        Jim_DecrRefCount(interp, tclOutput);
 
        for (i = 0; i < nwords; i++)
@@ -205,7 +209,7 @@ command_t* register_command(command_context_t *context, command_t *parent, char
        free((void *)full_name);
        
        /* we now need to add an overrideable proc */
-       const char *override_name=alloc_printf("proc %s%s%s {args} {return [eval \"ocd_%s%s%s $args\"]}", t1, t2, t3, t1, t2, t3);
+       const char *override_name=alloc_printf("proc %s%s%s {args} {if {[catch {eval \"ocd_%s%s%s $args\"}]==0} {return \"\"} else { return -code error }", t1, t2, t3, t1, t2, t3);
        Jim_Eval(interp, override_name);        
        free((void *)override_name);
        
@@ -651,6 +655,9 @@ command_context_t* command_init()
        
        add_default_dirs();
 
+#ifdef JIM_EMBEDDED
+       Jim_EventLoopOnLoad(interp);
+#endif
        if (Jim_Eval(interp, startup_tcl)==JIM_ERR)
        {
                LOG_ERROR("Failed to run startup.tcl (embedded into OpenOCD compile time)");
@@ -702,6 +709,20 @@ int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
        return ERROR_OK;
 }
 
+void process_jim_events() 
+{
+#ifdef JIM_EMBEDDED
+       static int recursion = 0;
+
+       if (!recursion) 
+       {
+               recursion++;
+               Jim_ProcessEvents (interp, JIM_ALL_EVENTS|JIM_DONT_WAIT);
+               recursion--;
+       }
+#endif
+}
+
 void register_jim(struct command_context_s *cmd_ctx, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help)
 {
        Jim_CreateCommand(interp, name, cmd, NULL, NULL);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)