From 30db43b5c566b498f39dfc63767277a0e8f347d2 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 5 Apr 2009 02:10:39 +0000 Subject: [PATCH] hush: fix passing of $n on NOMMU --- shell/hush.c | 12 ++++++++---- shell/hush_test/hush-vars/param_subshell.right | 7 +++++++ shell/hush_test/hush-vars/param_subshell.tests | 13 +++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 shell/hush_test/hush-vars/param_subshell.right create mode 100755 shell/hush_test/hush-vars/param_subshell.tests diff --git a/shell/hush.c b/shell/hush.c index 3388ad7f9..8ffdfb1a8 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2342,11 +2342,13 @@ static void re_execute_shell(const char *s) NORETURN; static void re_execute_shell(const char *s) { struct variable *cur; - char **argv, **pp; + char **argv, **pp, **pp2; unsigned cnt; - /* hush -$ -? -D ... -c NULL */ - cnt = 7; + /* 1:hush 2:-$ 3:-? 4:-D + * 5:-c 6: 7:NULL + */ + cnt = 7 + G.global_argc; for (cur = G.top_var; cur; cur = cur->next) { if (!cur->flg_export || cur->flg_read_only) cnt += 2; @@ -2370,7 +2372,9 @@ static void re_execute_shell(const char *s) } *pp++ = (char *) "-c"; *pp++ = (char *) s; -//TODO: pass $N + pp2 = G.global_argv; + while (*pp2) + *pp++ = *pp2++; *pp = NULL; //TODO: pass traps and functions diff --git a/shell/hush_test/hush-vars/param_subshell.right b/shell/hush_test/hush-vars/param_subshell.right new file mode 100644 index 000000000..f3c3767de --- /dev/null +++ b/shell/hush_test/hush-vars/param_subshell.right @@ -0,0 +1,7 @@ +1=1 +2=2 +3=3 +4=4 +5=5 +6=6 +7=7 diff --git a/shell/hush_test/hush-vars/param_subshell.tests b/shell/hush_test/hush-vars/param_subshell.tests new file mode 100755 index 000000000..6beaeae66 --- /dev/null +++ b/shell/hush_test/hush-vars/param_subshell.tests @@ -0,0 +1,13 @@ +if test $# = 0; then + "$THIS_SH" "$0" 1 2 3 4 5 6 7 8 9 + exit +fi +echo 1=$1 +{ echo 2=$2; } +{ echo 3=$3; } & +usleep 100000 +( echo 4=$4 ) +( echo 5=$5 ) & +usleep 100000 +true | echo 6=$6 | cat +true | { echo 7=$7; } | cat