--- cpukit/libmisc/shell/internal.h | 1 + cpukit/libmisc/shell/main_time.c | 10 +--------- cpukit/libmisc/shell/shell.c | 10 +--------- cpukit/libmisc/shell/shell_cmdset.c | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/cpukit/libmisc/shell/internal.h b/cpukit/libmisc/shell/internal.h index 1884117..e6d0ef1 100644 --- a/cpukit/libmisc/shell/internal.h +++ b/cpukit/libmisc/shell/internal.h @@ -25,6 +25,7 @@ extern rtems_shell_topic_t * rtems_shell_first_topic; rtems_shell_topic_t * rtems_shell_lookup_topic(const char *topic); +int rtems_shell_execute_cmd(const char *cmd, int argc, char *argv[]); extern void rtems_shell_register_monitor_commands(void); diff --git a/cpukit/libmisc/shell/main_time.c b/cpukit/libmisc/shell/main_time.c index e574647..401186a 100644 --- a/cpukit/libmisc/shell/main_time.c +++ b/cpukit/libmisc/shell/main_time.c @@ -38,7 +38,6 @@ static int rtems_shell_main_time( char *argv[] ) { - rtems_shell_cmd_t* shell_cmd; int errorlevel = 0; struct timespec start; struct timespec end; @@ -52,14 +51,7 @@ static int rtems_shell_main_time( fprintf(stderr, "error: cannot read time\n"); if (argc) { - shell_cmd = rtems_shell_lookup_cmd(argv[1]); - if ( argv[1] == NULL ) { - errorlevel = -1; - } else if ( shell_cmd == NULL ) { - errorlevel = rtems_shell_script_file(argc, &argv[1]); - } else { - errorlevel = shell_cmd->command(argc, &argv[1]); - } + errorlevel = rtems_shell_execute_cmd(argv[1], argc, &argv[1]); } sc = rtems_clock_get_uptime(&end); diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c index 6030ecc..5b74257 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -705,7 +705,6 @@ bool rtems_shell_main_loop( ) { rtems_shell_env_t *shell_env; - rtems_shell_cmd_t *shell_cmd; int eno; struct termios term; struct termios previous_term; @@ -917,14 +916,7 @@ bool rtems_shell_main_loop( memcpy (cmd_argv, cmds[cmd], RTEMS_SHELL_CMD_SIZE); if (!rtems_shell_make_args(cmd_argv, &argc, argv, RTEMS_SHELL_MAXIMUM_ARGUMENTS)) { - shell_cmd = rtems_shell_lookup_cmd(argv[0]); - if ( argv[0] == NULL ) { - shell_env->errorlevel = -1; - } else if ( shell_cmd == NULL ) { - shell_env->errorlevel = rtems_shell_script_file(argc, argv); - } else { - shell_env->errorlevel = shell_cmd->command(argc, argv); - } + shell_env->errorlevel = rtems_shell_execute_cmd(argv[0], argc, argv); } /* end exec cmd section */ diff --git a/cpukit/libmisc/shell/shell_cmdset.c b/cpukit/libmisc/shell/shell_cmdset.c index 2f2c246..07d37db 100644 --- a/cpukit/libmisc/shell/shell_cmdset.c +++ b/cpukit/libmisc/shell/shell_cmdset.c @@ -214,3 +214,20 @@ rtems_shell_cmd_t *rtems_shell_alias_cmd( } return shell_aux; } + +int rtems_shell_execute_cmd(const char *cmd, int argc, char *argv[]) +{ + rtems_shell_cmd_t *shell_cmd; + + if (argv[0] == NULL) { + return -1; + } + + shell_cmd = rtems_shell_lookup_cmd(argv[0]); + + if (shell_cmd == NULL) { + return rtems_shell_script_file(argc, argv); + } else { + return shell_cmd->command(argc, argv); + } +} -- 1.8.4.5 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel