hush: fix escaping of \[*?; add testsuites for these and for globbing
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 10 Jun 2008 20:13:40 +0000 (20:13 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 10 Jun 2008 20:13:40 +0000 (20:13 -0000)
shell/hush.c
shell/hush_test/hush-glob/glob1.right [new file with mode: 0644]
shell/hush_test/hush-glob/glob1.tests [new file with mode: 0755]
shell/hush_test/hush-parsing/escape1.right [new file with mode: 0644]
shell/hush_test/hush-parsing/escape1.tests [new file with mode: 0755]
shell/hush_test/hush-parsing/escape2.right [new file with mode: 0644]
shell/hush_test/hush-parsing/escape2.tests [new file with mode: 0755]

index 82bad664d771ddf769c1c090196b460705248894..e57f6e37164318b013abef8b35fcafa539f16522 100644 (file)
@@ -3638,7 +3638,6 @@ static int parse_stream(o_string *dest, struct p_context *ctx,
                                debug_printf_parse("parse_stream return 1: \\<eof>\n");
                                return 1;
                        }
-                       o_addqchr(dest, '\\', dest->o_quote);
                        o_addqchr(dest, i_getch(input), dest->o_quote);
                        break;
                case '$':
@@ -3653,7 +3652,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx,
                                ch = i_getch(input);
                                if (ch == EOF || ch == '\'')
                                        break;
-                               o_addchr(dest, ch);
+                               o_addqchr(dest, ch, 1);
                        }
                        if (ch == EOF) {
                                syntax("unterminated '");
diff --git a/shell/hush_test/hush-glob/glob1.right b/shell/hush_test/hush-glob/glob1.right
new file mode 100644 (file)
index 0000000..f29ab4e
--- /dev/null
@@ -0,0 +1,2 @@
+glob1.tests
+glob1.tests
diff --git a/shell/hush_test/hush-glob/glob1.tests b/shell/hush_test/hush-glob/glob1.tests
new file mode 100755 (executable)
index 0000000..f980ce0
--- /dev/null
@@ -0,0 +1,2 @@
+echo *glob1?t[e]sts*
+echo "glob1"?'t'[e]s*
diff --git a/shell/hush_test/hush-parsing/escape1.right b/shell/hush_test/hush-parsing/escape1.right
new file mode 100644 (file)
index 0000000..1899b87
--- /dev/null
@@ -0,0 +1,4 @@
+\
+a\b
+\\
+c\\d
diff --git a/shell/hush_test/hush-parsing/escape1.tests b/shell/hush_test/hush-parsing/escape1.tests
new file mode 100755 (executable)
index 0000000..67cfd1f
--- /dev/null
@@ -0,0 +1,4 @@
+echo "\\"
+echo a"\\"b
+echo '\\'
+echo c'\\'d
diff --git a/shell/hush_test/hush-parsing/escape2.right b/shell/hush_test/hush-parsing/escape2.right
new file mode 100644 (file)
index 0000000..f55fd4a
--- /dev/null
@@ -0,0 +1,4 @@
+*?[a]*
+a*?[a]*b
+*?[a]*
+c*?[a]*d
diff --git a/shell/hush_test/hush-parsing/escape2.tests b/shell/hush_test/hush-parsing/escape2.tests
new file mode 100755 (executable)
index 0000000..ee71801
--- /dev/null
@@ -0,0 +1,4 @@
+echo "*?[a]*"
+echo a"*?[a]*"b
+echo '*?[a]*'
+echo c'*?[a]*'d