From 2e76c3f9016f674dad7a38ec7ba5b068d233f189 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Tue, 10 Jun 2008 18:27:50 +0000 Subject: hush: fix yet another fallout hush: move fixed testsuites out of hush-bugs/* --- shell/hush.c | 25 ++++++++++++------------- shell/hush_test/hush-bugs/tick.right | 2 -- shell/hush_test/hush-bugs/tick.tests | 4 ---- shell/hush_test/hush-bugs/tick2.right | 1 - shell/hush_test/hush-bugs/tick2.tests | 6 ------ shell/hush_test/hush-psubst/tick.right | 2 ++ shell/hush_test/hush-psubst/tick.tests | 4 ++++ shell/hush_test/hush-psubst/tick2.right | 1 + shell/hush_test/hush-psubst/tick2.tests | 5 +++++ 9 files changed, 24 insertions(+), 26 deletions(-) delete mode 100644 shell/hush_test/hush-bugs/tick.right delete mode 100755 shell/hush_test/hush-bugs/tick.tests delete mode 100644 shell/hush_test/hush-bugs/tick2.right delete mode 100755 shell/hush_test/hush-bugs/tick2.tests create mode 100644 shell/hush_test/hush-psubst/tick.right create mode 100755 shell/hush_test/hush-psubst/tick.tests create mode 100644 shell/hush_test/hush-psubst/tick2.right create mode 100755 shell/hush_test/hush-psubst/tick2.tests 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-bugs/tick.right deleted file mode 100644 index 6ed281c75..000000000 --- a/shell/hush_test/hush-bugs/tick.right +++ /dev/null @@ -1,2 +0,0 @@ -1 -1 diff --git a/shell/hush_test/hush-bugs/tick.tests b/shell/hush_test/hush-bugs/tick.tests deleted file mode 100755 index 1f749a9cd..000000000 --- a/shell/hush_test/hush-bugs/tick.tests +++ /dev/null @@ -1,4 +0,0 @@ -true -false; echo `echo $?` -true -{ false; echo `echo $?`; } diff --git a/shell/hush_test/hush-bugs/tick2.right b/shell/hush_test/hush-bugs/tick2.right deleted file mode 100644 index 216c883b8..000000000 --- a/shell/hush_test/hush-bugs/tick2.right +++ /dev/null @@ -1 +0,0 @@ -BAZ diff --git a/shell/hush_test/hush-bugs/tick2.tests b/shell/hush_test/hush-bugs/tick2.tests deleted file mode 100755 index dc518057c..000000000 --- a/shell/hush_test/hush-bugs/tick2.tests +++ /dev/null @@ -1,6 +0,0 @@ -# Bag: backticks are executed even inside not-taken if -if false; then - echo "FOO" - tmp=`echo BAR >&2` -fi -echo BAZ diff --git a/shell/hush_test/hush-psubst/tick.right b/shell/hush_test/hush-psubst/tick.right new file mode 100644 index 000000000..6ed281c75 --- /dev/null +++ b/shell/hush_test/hush-psubst/tick.right @@ -0,0 +1,2 @@ +1 +1 diff --git a/shell/hush_test/hush-psubst/tick.tests b/shell/hush_test/hush-psubst/tick.tests new file mode 100755 index 000000000..1f749a9cd --- /dev/null +++ b/shell/hush_test/hush-psubst/tick.tests @@ -0,0 +1,4 @@ +true +false; echo `echo $?` +true +{ false; echo `echo $?`; } diff --git a/shell/hush_test/hush-psubst/tick2.right b/shell/hush_test/hush-psubst/tick2.right new file mode 100644 index 000000000..216c883b8 --- /dev/null +++ b/shell/hush_test/hush-psubst/tick2.right @@ -0,0 +1 @@ +BAZ diff --git a/shell/hush_test/hush-psubst/tick2.tests b/shell/hush_test/hush-psubst/tick2.tests new file mode 100755 index 000000000..db4e944fe --- /dev/null +++ b/shell/hush_test/hush-psubst/tick2.tests @@ -0,0 +1,5 @@ +if false; then + echo "FOO" + tmp=`echo BAR >&2` +fi +echo BAZ -- cgit v1.2.3