diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-03-05 02:49:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-03-05 02:49:35 +0000 |
commit | a3ddb08bec11871f6e83bb7aaa53a17a4ea5309c (patch) | |
tree | 7a77642c272052b03260156dc5062d23f16e3a35 /cpukit/libmisc/shell/shell.c | |
parent | New. (diff) | |
download | rtems-a3ddb08bec11871f6e83bb7aaa53a17a4ea5309c.tar.bz2 |
2008-03-04 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_cp.c,
libmisc/shell/main_cpuuse.c, libmisc/shell/main_date.c,
libmisc/shell/main_mallocinfo.c, libmisc/shell/main_netstats.c,
libmisc/shell/main_perioduse.c, libmisc/shell/main_stackuse.c,
libmisc/shell/main_wkspaceinfo.c, libmisc/shell/print_heapinfo.c,
libmisc/shell/shell.c, libmisc/shell/shell.h,
libmisc/shell/shell_makeargs.c, libmisc/shell/shellconfig.c,
libmisc/shell/shellconfig.h, libmisc/shell/write_file.c: Add initial
capability to automatically execute a script from the filesystem. Add
echo command from NetBSD and sleep command.
* libmisc/shell/main_echo.c, libmisc/shell/main_sleep.c,
libmisc/shell/shell_script.c: New files.
Diffstat (limited to 'cpukit/libmisc/shell/shell.c')
-rw-r--r-- | cpukit/libmisc/shell/shell.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c index eca05f19e8..264742a246 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -208,7 +208,7 @@ int rtems_shell_login(FILE * in,FILE * out) { fprintf(out,"RTEMS"); break; case 'V': - fprintf(out,"%s\n%s",_RTEMS_version,_Copyright_Notice); + fprintf(out,"%s\n%s",_RTEMS_version, _Copyright_Notice); break; case '@': fprintf(out,"@"); @@ -371,6 +371,8 @@ rtems_boolean rtems_shell_main_loop( rtems_boolean result = TRUE; rtems_boolean input_file = FALSE; int line = 0; + FILE *stdinToClose = NULL; + FILE *stdoutToClose = NULL; rtems_shell_initialize_command_set(); @@ -397,8 +399,9 @@ rtems_boolean rtems_shell_main_loop( fileno(stdout); -fprintf( stderr, - "-%s-%s-\n", shell_env->input, shell_env->output ); + /* fprintf( stderr, + "-%s-%s-\n", shell_env->input, shell_env->output ); + */ if (shell_env->output && strcmp(shell_env->output, "stdout") != 0) { if (strcmp(shell_env->output, "stderr") == 0) { @@ -414,6 +417,7 @@ fprintf( stderr, return FALSE; } stdout = output; + stdoutToClose = output; } } @@ -425,6 +429,7 @@ fprintf( stderr, return FALSE; } stdin = input; + stdinToClose = input; shell_env->forever = FALSE; input_file = TRUE; } @@ -534,8 +539,7 @@ fprintf( stderr, if ( argv[0] == NULL ) { shell_env->errorlevel = -1; } else if ( shell_cmd == NULL ) { - fprintf(stdout, "shell:%s command not found\n", argv[0]); - shell_env->errorlevel = -1; + shell_env->errorlevel = rtems_shell_script_file( argc, argv ); } else { shell_env->errorlevel = shell_cmd->command(argc, argv); } @@ -551,6 +555,10 @@ fprintf( stderr, fflush( stderr ); } } while (result && shell_env->forever); + if ( stdinToClose ) + fclose( stdinToClose ); + if ( stdoutToClose ) + fclose( stdoutToClose ); return result; } |