svn commit: [25771] trunk/busybox/shell: hush_test/hush-parsing
vda at busybox.net
vda at busybox.net
Fri Mar 20 12:05:14 UTC 2009
Author: vda
Date: 2009-03-20 12:05:14 +0000 (Fri, 20 Mar 2009)
New Revision: 25771
Log:
hush: fix bug 207 and "hush -c" parameter passing.
Now hush -c 'printf "%s\n" "$@"' (prints "\n")
and hush -c 'printf "%s\n" "$@"' qwe asd (prints "asd\n")
both work correctly
Modified:
trunk/busybox/shell/hush.c
trunk/busybox/shell/hush_test/hush-parsing/starquoted2.right
trunk/busybox/shell/hush_test/hush-parsing/starquoted2.tests
Changeset:
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c 2009-03-20 10:20:08 UTC (rev 25770)
+++ trunk/busybox/shell/hush.c 2009-03-20 12:05:14 UTC (rev 25771)
@@ -1219,8 +1219,13 @@
* Otherwise, just finish current list[] and start new */
static int o_save_ptr(o_string *o, int n)
{
- if (o->o_glob)
- return o_glob(o, n); /* o_save_ptr_helper is inside */
+ if (o->o_glob) { /* if globbing is requested */
+ /* If o->has_empty_slot, list[n] was already globbed
+ * (if it was requested back then when it was filled)
+ * so don't do that again! */
+ if (!o->has_empty_slot)
+ return o_glob(o, n); /* o_save_ptr_helper is inside */
+ }
return o_save_ptr_helper(o, n);
}
@@ -4285,6 +4290,11 @@
switch (opt) {
case 'c':
G.global_argv = argv + optind;
+ if (!argv[optind]) {
+ /* -c 'script' (no params): prevent empty $0 */
+ *--G.global_argv = argv[0];
+ optind--;
+ } /* else -c 'script' PAR0 PAR1: $0 is PAR0 */
G.global_argc = argc - optind;
opt = parse_and_run_string(optarg, 0 /* parse_flag */);
goto final_return;
Modified: trunk/busybox/shell/hush_test/hush-parsing/starquoted2.right
===================================================================
--- trunk/busybox/shell/hush_test/hush-parsing/starquoted2.right 2009-03-20 10:20:08 UTC (rev 25770)
+++ trunk/busybox/shell/hush_test/hush-parsing/starquoted2.right 2009-03-20 12:05:14 UTC (rev 25771)
@@ -1,2 +1,3 @@
Should be printed
Should be printed
+Empty:
Modified: trunk/busybox/shell/hush_test/hush-parsing/starquoted2.tests
===================================================================
--- trunk/busybox/shell/hush_test/hush-parsing/starquoted2.tests 2009-03-20 10:20:08 UTC (rev 25770)
+++ trunk/busybox/shell/hush_test/hush-parsing/starquoted2.tests 2009-03-20 12:05:14 UTC (rev 25771)
@@ -12,3 +12,6 @@
for a in """$@"; do echo Should not be printed; done
for a in """$@"''"$@"''; do echo Should not be printed; done
for a in ""; do echo Should be printed; done
+
+# Bug 207: "$@" expands to nothing, and we erroneously glob "%s\\n" twice:
+printf "Empty:%s\\n" "$@"
More information about the busybox-cvs
mailing list