summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/command.c8
-rw-r--r--src/helper/command.h4
2 files changed, 10 insertions, 2 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index 3625508f..be262f2e 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -167,14 +167,18 @@ static const char **script_command_args_alloc(
return words;
}
-static struct command_context *current_command_context(Jim_Interp *interp)
+struct command_context *current_command_context(Jim_Interp *interp)
{
/* grab the command context from the associated data */
struct command_context *cmd_ctx = Jim_GetAssocData(interp, "context");
if (NULL == cmd_ctx)
{
/* Tcl can invoke commands directly instead of via command_run_line(). This would
- * happen when the Jim Tcl interpreter is provided by eCos.
+ * happen when the Jim Tcl interpreter is provided by eCos or if we are running
+ * commands in a startup script.
+ *
+ * A telnet or gdb server would provide a non-default command context to
+ * handle piping of error output, have a separate current target, etc.
*/
cmd_ctx = global_cmd_ctx;
}
diff --git a/src/helper/command.h b/src/helper/command.h
index 8a418d36..2c192416 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -311,6 +311,10 @@ void command_set_output_handler(struct command_context* context,
int command_context_mode(struct command_context *context, enum command_mode mode);
+/* Return the current command context associated with the Jim interpreter or
+ * alternatively the global default command interpreter
+ */
+struct command_context *current_command_context(Jim_Interp *interp);
/**
* Creates a new command context using the startup TCL provided and
* the existing Jim interpreter, if any. If interp == NULL, then command_init