From 8a33679694b0fdf459d69868f85c081cab5687cb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 22 May 2010 06:05:02 +0200 Subject: hush: fix "hush -c 'echo $#'" showing -1 Signed-off-by: Denys Vlasenko --- shell/hush.c | 1 - shell/hush_test/hush-vars/param_expand_len.right | 5 +++++ shell/hush_test/hush-vars/param_expand_len.tests | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 41d5fcab2..7645a34a4 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -7080,7 +7080,6 @@ int hush_main(int argc, char **argv) /* -c 'script' (no params): prevent empty $0 */ G.global_argv--; /* points to argv[i] of 'script' */ G.global_argv[0] = argv[0]; - G.global_argc--; } /* else -c 'script' ARG0 [ARG1...]: $0 is ARG0 */ init_sigmasks(); parse_and_run_string(optarg); diff --git a/shell/hush_test/hush-vars/param_expand_len.right b/shell/hush_test/hush-vars/param_expand_len.right index 2d633a148..96e8cb59b 100644 --- a/shell/hush_test/hush-vars/param_expand_len.right +++ b/shell/hush_test/hush-vars/param_expand_len.right @@ -1,4 +1,9 @@ +0 +0 +1 +Make sure len parsing doesnt break arg count 0 0 4 4 +Testing len op 4 3 2 1 0 0 0 3 0 diff --git a/shell/hush_test/hush-vars/param_expand_len.tests b/shell/hush_test/hush-vars/param_expand_len.tests index 90f47d2fb..fe20a45e9 100755 --- a/shell/hush_test/hush-vars/param_expand_len.tests +++ b/shell/hush_test/hush-vars/param_expand_len.tests @@ -1,9 +1,14 @@ -# make sure len parsing doesnt break arg count +"$THIS_SH" -c 'echo $#' +"$THIS_SH" -c 'echo $#' arg0 +"$THIS_SH" -c 'echo $#' arg0 arg1 + +echo Make sure len parsing doesnt break arg count set -- echo $# ${#} set -- aaaa bbb cc d echo $# ${#} +echo Testing len op echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6} unset e -- cgit v1.2.3