From 7840b66f74005f3d6ddd590b9ab40945e1c1f827 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 18 Nov 2014 10:03:24 +0100 Subject: shell: Add initial commands and aliases only once Make tables read-only. --- cpukit/libmisc/shell/shell.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'cpukit/libmisc/shell/shell.c') diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c index 9a5ffb55b4..6030eccbc6 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -112,6 +112,20 @@ static void rtems_shell_create_file(const char *name, const char *content) } } +static void rtems_shell_init_commands(void) +{ + rtems_shell_cmd_t * const *c; + rtems_shell_alias_t * const *a; + + for ( c = rtems_shell_Initial_commands ; *c ; c++ ) { + rtems_shell_add_cmd_struct( *c ); + } + + for ( a = rtems_shell_Initial_aliases ; *a ; a++ ) { + rtems_shell_alias_cmd( (*a)->name, (*a)->alias ); + } +} + static void rtems_shell_init_once(void) { struct passwd pwd; @@ -131,6 +145,8 @@ static void rtems_shell_init_once(void) "\n" "Welcome to %v\n" "running on %m\n"); + + rtems_shell_init_commands(); } /* @@ -706,11 +722,11 @@ bool rtems_shell_main_loop( FILE *stdinToClose = NULL; FILE *stdoutToClose = NULL; - rtems_shell_initialize_command_set(); - eno = pthread_once(&rtems_shell_once, rtems_shell_init_once); assert(eno == 0); + rtems_shell_register_monitor_commands(); + shell_env = rtems_shell_init_env(shell_env_arg); if (shell_env == NULL) { rtems_error(0, "rtems_shell_init_env"); @@ -790,8 +806,6 @@ bool rtems_shell_main_loop( setvbuf(stdin,NULL,_IONBF,0); /* Not buffered*/ setvbuf(stdout,NULL,_IONBF,0); /* Not buffered*/ - rtems_shell_initialize_command_set(); - /* * Allocate the command line buffers. */ -- cgit v1.2.3