hush: fix "hush -c 'echo $#'" showing -1
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 22 May 2010 04:05:02 +0000 (06:05 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 22 May 2010 04:05:02 +0000 (06:05 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/hush.c
shell/hush_test/hush-vars/param_expand_len.right
shell/hush_test/hush-vars/param_expand_len.tests

index 41d5fcab2f242b42a10725de1f9093a2f1e64145..7645a34a4f8a1d351d4295ae872d1538b81369ab 100644 (file)
@@ -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);
index 2d633a1487cd7b40511708cca17d26d4d4176390..96e8cb59b68a6b53f8226b69e5ae528cb3a48e9d 100644 (file)
@@ -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
index 90f47d2fb24218822861676c00681121e416c1ba..fe20a45e957bf55e2af66a2fdf6d3107cac8d99a 100755 (executable)
@@ -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