aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-22 06:05:02 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-22 06:05:02 +0200
commit8a33679694b0fdf459d69868f85c081cab5687cb (patch)
treebe6d2ea8d9a5132d82939892736d2531877632e8
parent1e811b12317d0eab4e78d848caa640cca497a0a7 (diff)
downloadbusybox-w32-8a33679694b0fdf459d69868f85c081cab5687cb.tar.gz
busybox-w32-8a33679694b0fdf459d69868f85c081cab5687cb.tar.bz2
busybox-w32-8a33679694b0fdf459d69868f85c081cab5687cb.zip
hush: fix "hush -c 'echo $#'" showing -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c1
-rw-r--r--shell/hush_test/hush-vars/param_expand_len.right5
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_len.tests7
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)
7080 /* -c 'script' (no params): prevent empty $0 */ 7080 /* -c 'script' (no params): prevent empty $0 */
7081 G.global_argv--; /* points to argv[i] of 'script' */ 7081 G.global_argv--; /* points to argv[i] of 'script' */
7082 G.global_argv[0] = argv[0]; 7082 G.global_argv[0] = argv[0];
7083 G.global_argc--;
7084 } /* else -c 'script' ARG0 [ARG1...]: $0 is ARG0 */ 7083 } /* else -c 'script' ARG0 [ARG1...]: $0 is ARG0 */
7085 init_sigmasks(); 7084 init_sigmasks();
7086 parse_and_run_string(optarg); 7085 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 @@
10
20
31
4Make sure len parsing doesnt break arg count
10 0 50 0
24 4 64 4
7Testing len op
34 3 2 1 0 0 84 3 2 1 0 0
40 3 0 90 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 @@
1# make sure len parsing doesnt break arg count 1"$THIS_SH" -c 'echo $#'
2"$THIS_SH" -c 'echo $#' arg0
3"$THIS_SH" -c 'echo $#' arg0 arg1
4
5echo Make sure len parsing doesnt break arg count
2set -- 6set --
3echo $# ${#} 7echo $# ${#}
4set -- aaaa bbb cc d 8set -- aaaa bbb cc d
5echo $# ${#} 9echo $# ${#}
6 10
11echo Testing len op
7echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6} 12echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6}
8 13
9unset e 14unset e