From a3ddb08bec11871f6e83bb7aaa53a17a4ea5309c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 5 Mar 2008 02:49:35 +0000 Subject: 2008-03-04 Joel Sherrill * 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. --- cpukit/libmisc/shell/shell.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'cpukit/libmisc/shell/shell.c') 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; } -- cgit v1.2.3