From 55c64fc9cd8ddd7a3d4b3207b9c9c698c7a9ec4b Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Fri, 11 Apr 2008 22:57:54 +0000 Subject: 2008-04-12 Chris Johns * libmisc/shell/shell.c, libmisc/shell/shell.h, libmisc/shell/shell_script.c: Add support to echo the commands to stdout. This is useful with the -v script option to show commands as the run. Also added support to chdir to the directory the task invoking the script is in. * libmisc/shell/extern-cp.h, libmisc/shell/main_cp.c, libmisc/shell/utils-cp.c: Update tro the latest FreeBSD version. * libcsupport/Makefile.am, libcsupport/src/fchown.c: Add fchown support. --- cpukit/libmisc/shell/shell.c | 22 +++++++++++++++++----- 1 file changed, 17 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 76ca6c0d7b..a857e7bfa3 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -806,8 +806,12 @@ rtems_boolean rtems_shell_main_loop( __DATE__". 'help' to list commands.\n", shell_env->devname); } + + if (input_file) + chdir(shell_env->cwd); + else + chdir("/"); /* XXX: chdir to getpwent homedir */ - chdir("/"); /* XXX: chdir to getpwent homedir */ shell_env->exit_shell = FALSE; for (;;) { @@ -832,6 +836,9 @@ rtems_boolean rtems_shell_main_loop( line++; + if (shell_env->echo) + fprintf(stdout, "%d: %s\n", line, cmds[cmd]); + /* evaluate cmd section */ c = cmds[cmd]; while (*c) { @@ -911,7 +918,8 @@ static rtems_status_code rtems_shell_run ( const char* input, const char* output, int output_append, - rtems_id wake_on_end + rtems_id wake_on_end, + int echo ) { rtems_id task_id; @@ -949,11 +957,14 @@ static rtems_status_code rtems_shell_run ( shell_env->tcflag = tcflag; shell_env->exit_shell = FALSE; shell_env->forever = forever; + shell_env->echo = echo; shell_env->input = strdup (input); shell_env->output = strdup (output); shell_env->output_append = output_append; shell_env->wake_on_end = wake_on_end; + getcwd(shell_env->cwd, sizeof(shell_env->cwd)); + return rtems_task_start(task_id, rtems_shell_task, (rtems_task_argument) shell_env); } @@ -969,7 +980,7 @@ rtems_status_code rtems_shell_init ( { return rtems_shell_run (task_name, task_stacksize, task_priority, devname, tcflag, forever, - "stdin", "stdout", 0, RTEMS_INVALID_ID); + "stdin", "stdout", 0, RTEMS_INVALID_ID, 0); } rtems_status_code rtems_shell_script ( @@ -979,7 +990,8 @@ rtems_status_code rtems_shell_script ( const char* input, const char* output, int output_append, - int wait + int wait, + int echo ) { rtems_id current_task = RTEMS_INVALID_ID; @@ -993,7 +1005,7 @@ rtems_status_code rtems_shell_script ( sc = rtems_shell_run (task_name, task_stacksize, task_priority, NULL, 0, 0, input, output, output_append, - current_task); + current_task, echo); if (sc != RTEMS_SUCCESSFUL) return sc; -- cgit v1.2.3