summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell/shell.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-18 10:03:24 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-20 10:30:25 +0100
commit7840b66f74005f3d6ddd590b9ab40945e1c1f827 (patch)
treeb97b898e4f40b1934a4a3b4518f08115aa28ba07 /cpukit/libmisc/shell/shell.c
parentshell: Simplify rtems_shell_add_cmd_struct() (diff)
downloadrtems-7840b66f74005f3d6ddd590b9ab40945e1c1f827.tar.bz2
shell: Add initial commands and aliases only once
Make tables read-only.
Diffstat (limited to 'cpukit/libmisc/shell/shell.c')
-rw-r--r--cpukit/libmisc/shell/shell.c22
1 files changed, 18 insertions, 4 deletions
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.
*/