shell: Add shell_exec

This adds shell_exec which can be used to execute commands directly
without the use of a console which is useful for both testing as well
as interfacing with applications/upper layer which would like to have
access to shell commands directly.

In addition to that this may be more trivial to interface with instead
of using fifos like uart_register_input and telnet_register_input do.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2017-05-25 21:14:08 +03:00 committed by Anas Nashif
commit 1a8cd31d64
2 changed files with 46 additions and 23 deletions

View file

@ -119,6 +119,22 @@ void shell_register_prompt_handler(shell_prompt_function_t handler);
*/
void shell_register_default_module(const char *name);
/** @brief Execute command line.
*
* Pass command line to shell to execute. The line cannot be a C string literal
* since it will be modified in place, instead a variable can be used:
*
* char cmd[] = "command";
* shell_exec(cmd);
*
* Note: This by no means makes any of the commands a stable interface, so
* this function should only be used for debugging/diagnostic.
*
* @param line Command line to be executed
* @returns Result of the execution
*/
int shell_exec(char *line);
/**
* @}
*/