From 2e76c3f9016f674dad7a38ec7ba5b068d233f189 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Tue, 10 Jun 2008 18:27:50 +0000 Subject: [PATCH] hush: fix yet another fallout hush: move fixed testsuites out of hush-bugs/* --- shell/hush.c | 25 +++++++++---------- .../{hush-bugs => hush-psubst}/tick.right | 0 .../{hush-bugs => hush-psubst}/tick.tests | 0 .../{hush-bugs => hush-psubst}/tick2.right | 0 .../{hush-bugs => hush-psubst}/tick2.tests | 1 - 5 files changed, 12 insertions(+), 14 deletions(-) rename shell/hush_test/{hush-bugs => hush-psubst}/tick.right (100%) rename shell/hush_test/{hush-bugs => hush-psubst}/tick.tests (100%) rename shell/hush_test/{hush-bugs => hush-psubst}/tick2.right (100%) rename shell/hush_test/{hush-bugs => hush-psubst}/tick2.tests (54%) diff --git a/shell/hush.c b/shell/hush.c index 603e19fe9..82bad664d 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2691,19 +2691,18 @@ static int expand_vars_to_list(o_string *output, int n, char *arg, char or_mask) arg = ++p; } /* end of "while (SPECIAL_VAR_SYMBOL is found) ..." */ - { - int len = strlen(arg); - if (len) { - o_debug_list("expand_vars_to_list[a]", output, n); - o_addstr(output, arg, len + 1); - o_debug_list("expand_vars_to_list[b]", output, n); - } else if (output->length == o_get_last_ptr(output, n)) { /* expansion is empty */ - if (!(ored_ch & 0x80)) { /* all vars were not quoted... */ - n--; - /* allow to reuse list[n] later without re-growth */ - output->has_empty_slot = 1; - } - } + if (arg[0]) { + o_debug_list("expand_vars_to_list[a]", output, n); + o_addstr(output, arg, strlen(arg) + 1); + o_debug_list("expand_vars_to_list[b]", output, n); + } else if (output->length == o_get_last_ptr(output, n) /* expansion is empty */ + && !(ored_ch & 0x80) /* and all vars were not quoted. */ + ) { + n--; + /* allow to reuse list[n] later without re-growth */ + output->has_empty_slot = 1; + } else { + o_addchr(output, '\0'); } return n; } diff --git a/shell/hush_test/hush-bugs/tick.right b/shell/hush_test/hush-psubst/tick.right similarity index 100% rename from shell/hush_test/hush-bugs/tick.right rename to shell/hush_test/hush-psubst/tick.right diff --git a/shell/hush_test/hush-bugs/tick.tests b/shell/hush_test/hush-psubst/tick.tests similarity index 100% rename from shell/hush_test/hush-bugs/tick.tests rename to shell/hush_test/hush-psubst/tick.tests diff --git a/shell/hush_test/hush-bugs/tick2.right b/shell/hush_test/hush-psubst/tick2.right similarity index 100% rename from shell/hush_test/hush-bugs/tick2.right rename to shell/hush_test/hush-psubst/tick2.right diff --git a/shell/hush_test/hush-bugs/tick2.tests b/shell/hush_test/hush-psubst/tick2.tests similarity index 54% rename from shell/hush_test/hush-bugs/tick2.tests rename to shell/hush_test/hush-psubst/tick2.tests index dc518057c..db4e944fe 100755 --- a/shell/hush_test/hush-bugs/tick2.tests +++ b/shell/hush_test/hush-psubst/tick2.tests @@ -1,4 +1,3 @@ -# Bag: backticks are executed even inside not-taken if if false; then echo "FOO" tmp=`echo BAR >&2`