diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-10 20:13:40 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-06-10 20:13:40 +0000 |
commit | 43360e51781942730f91bb19821e3f8f1087e4fa (patch) | |
tree | aed87780129aa4f24a47c868c1067bf44b92a55b /shell | |
parent | 2e76c3f9016f674dad7a38ec7ba5b068d233f189 (diff) | |
download | busybox-w32-43360e51781942730f91bb19821e3f8f1087e4fa.tar.gz busybox-w32-43360e51781942730f91bb19821e3f8f1087e4fa.tar.bz2 busybox-w32-43360e51781942730f91bb19821e3f8f1087e4fa.zip |
hush: fix escaping of \[*?; add testsuites for these and for globbing
Diffstat (limited to 'shell')
-rw-r--r-- | shell/hush.c | 3 | ||||
-rw-r--r-- | shell/hush_test/hush-glob/glob1.right | 2 | ||||
-rwxr-xr-x | shell/hush_test/hush-glob/glob1.tests | 2 | ||||
-rw-r--r-- | shell/hush_test/hush-parsing/escape1.right | 4 | ||||
-rwxr-xr-x | shell/hush_test/hush-parsing/escape1.tests | 4 | ||||
-rw-r--r-- | shell/hush_test/hush-parsing/escape2.right | 4 | ||||
-rwxr-xr-x | shell/hush_test/hush-parsing/escape2.tests | 4 |
7 files changed, 21 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c index 82bad664d..e57f6e371 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -3638,7 +3638,6 @@ static int parse_stream(o_string *dest, struct p_context *ctx, | |||
3638 | debug_printf_parse("parse_stream return 1: \\<eof>\n"); | 3638 | debug_printf_parse("parse_stream return 1: \\<eof>\n"); |
3639 | return 1; | 3639 | return 1; |
3640 | } | 3640 | } |
3641 | o_addqchr(dest, '\\', dest->o_quote); | ||
3642 | o_addqchr(dest, i_getch(input), dest->o_quote); | 3641 | o_addqchr(dest, i_getch(input), dest->o_quote); |
3643 | break; | 3642 | break; |
3644 | case '$': | 3643 | case '$': |
@@ -3653,7 +3652,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx, | |||
3653 | ch = i_getch(input); | 3652 | ch = i_getch(input); |
3654 | if (ch == EOF || ch == '\'') | 3653 | if (ch == EOF || ch == '\'') |
3655 | break; | 3654 | break; |
3656 | o_addchr(dest, ch); | 3655 | o_addqchr(dest, ch, 1); |
3657 | } | 3656 | } |
3658 | if (ch == EOF) { | 3657 | if (ch == EOF) { |
3659 | syntax("unterminated '"); | 3658 | syntax("unterminated '"); |
diff --git a/shell/hush_test/hush-glob/glob1.right b/shell/hush_test/hush-glob/glob1.right new file mode 100644 index 000000000..f29ab4e65 --- /dev/null +++ b/shell/hush_test/hush-glob/glob1.right | |||
@@ -0,0 +1,2 @@ | |||
1 | glob1.tests | ||
2 | glob1.tests | ||
diff --git a/shell/hush_test/hush-glob/glob1.tests b/shell/hush_test/hush-glob/glob1.tests new file mode 100755 index 000000000..f980ce064 --- /dev/null +++ b/shell/hush_test/hush-glob/glob1.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | echo *glob1?t[e]sts* | ||
2 | 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 index 000000000..1899b87ef --- /dev/null +++ b/shell/hush_test/hush-parsing/escape1.right | |||
@@ -0,0 +1,4 @@ | |||
1 | \ | ||
2 | a\b | ||
3 | \\ | ||
4 | c\\d | ||
diff --git a/shell/hush_test/hush-parsing/escape1.tests b/shell/hush_test/hush-parsing/escape1.tests new file mode 100755 index 000000000..67cfd1fef --- /dev/null +++ b/shell/hush_test/hush-parsing/escape1.tests | |||
@@ -0,0 +1,4 @@ | |||
1 | echo "\\" | ||
2 | echo a"\\"b | ||
3 | echo '\\' | ||
4 | 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 index 000000000..f55fd4a42 --- /dev/null +++ b/shell/hush_test/hush-parsing/escape2.right | |||
@@ -0,0 +1,4 @@ | |||
1 | *?[a]* | ||
2 | a*?[a]*b | ||
3 | *?[a]* | ||
4 | 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 index 000000000..ee718018d --- /dev/null +++ b/shell/hush_test/hush-parsing/escape2.tests | |||
@@ -0,0 +1,4 @@ | |||
1 | echo "*?[a]*" | ||
2 | echo a"*?[a]*"b | ||
3 | echo '*?[a]*' | ||
4 | echo c'*?[a]*'d | ||