diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-13 19:14:27 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-01-13 19:14:27 +0100 |
commit | 9809a82b5983ac3184906fff2df48765dab372c8 (patch) | |
tree | c546d6d19616ebdc0bef6bf0cb48a067816ee586 | |
parent | 6606c519efa9a74c53bf05e53e07a8d8f0eb37c7 (diff) | |
download | busybox-w32-9809a82b5983ac3184906fff2df48765dab372c8.tar.gz busybox-w32-9809a82b5983ac3184906fff2df48765dab372c8.tar.bz2 busybox-w32-9809a82b5983ac3184906fff2df48765dab372c8.zip |
hush: fix raw ^C handlisg in single-quoted strings
function old new delta
parse_stream 2719 2754 +35
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash_test/ash-misc/control_char1.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-misc/control_char1.tests | 1 | ||||
-rw-r--r-- | shell/ash_test/ash-misc/for_with_bslashes.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-misc/for_with_bslashes.tests | 8 | ||||
-rw-r--r-- | shell/hush.c | 5 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/control_char1.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/control_char1.tests | 1 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/for_with_bslashes.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/for_with_bslashes.tests | 8 |
9 files changed, 15 insertions, 12 deletions
diff --git a/shell/ash_test/ash-misc/control_char1.right b/shell/ash_test/ash-misc/control_char1.right index 9498b420d..6f8c2533c 100644 --- a/shell/ash_test/ash-misc/control_char1.right +++ b/shell/ash_test/ash-misc/control_char1.right | |||
@@ -1,2 +1,3 @@ | |||
1 | 1 | ||
2 | b#c | ||
2 | Done:0 | 3 | Done:0 |
diff --git a/shell/ash_test/ash-misc/control_char1.tests b/shell/ash_test/ash-misc/control_char1.tests index a2ebeba1b..0cfe60141 100755 --- a/shell/ash_test/ash-misc/control_char1.tests +++ b/shell/ash_test/ash-misc/control_char1.tests | |||
@@ -1,2 +1,3 @@ | |||
1 | echo | 1 | echo |
2 | echo 'b#c' | ||
2 | echo Done:$? | 3 | echo Done:$? |
diff --git a/shell/ash_test/ash-misc/for_with_bslashes.right b/shell/ash_test/ash-misc/for_with_bslashes.right index 02d96692c..cd8501050 100644 --- a/shell/ash_test/ash-misc/for_with_bslashes.right +++ b/shell/ash_test/ash-misc/for_with_bslashes.right | |||
@@ -5,4 +5,5 @@ b"c | |||
5 | b'c | 5 | b'c |
6 | b$c | 6 | b$c |
7 | b`true`c | 7 | b`true`c |
8 | b#c | ||
8 | Zero:0 | 9 | Zero:0 |
diff --git a/shell/ash_test/ash-misc/for_with_bslashes.tests b/shell/ash_test/ash-misc/for_with_bslashes.tests index 363f3d85b..8acd9808a 100755 --- a/shell/ash_test/ash-misc/for_with_bslashes.tests +++ b/shell/ash_test/ash-misc/for_with_bslashes.tests | |||
@@ -1,9 +1,5 @@ | |||
1 | # UNFIXED BUG. | 1 | # last word contains ^C character. |
2 | # commented-out words contain ^C character. | 2 | for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' 'b#c' |
3 | # It's a SPECIAL_VAR_SYMBOL, for now hush does not escape it. | ||
4 | # When it is fixed, update this test. | ||
5 | |||
6 | for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' ### 'b#c' | ||
7 | do | 3 | do |
8 | echo $a | 4 | echo $a |
9 | done | 5 | done |
diff --git a/shell/hush.c b/shell/hush.c index fc8940d3d..79d7a53dd 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -5225,6 +5225,11 @@ static struct pipe *parse_stream(char **pstring, | |||
5225 | nommu_addchr(&ctx.as_string, ch); | 5225 | nommu_addchr(&ctx.as_string, ch); |
5226 | if (ch == '\'') | 5226 | if (ch == '\'') |
5227 | break; | 5227 | break; |
5228 | if (ch == SPECIAL_VAR_SYMBOL) { | ||
5229 | /* Convert raw ^C to corresponding special variable reference */ | ||
5230 | o_addchr(&dest, SPECIAL_VAR_SYMBOL); | ||
5231 | o_addchr(&dest, SPECIAL_VAR_QUOTED_SVS); | ||
5232 | } | ||
5228 | o_addqchr(&dest, ch); | 5233 | o_addqchr(&dest, ch); |
5229 | } | 5234 | } |
5230 | } | 5235 | } |
diff --git a/shell/hush_test/hush-misc/control_char1.right b/shell/hush_test/hush-misc/control_char1.right index 9498b420d..6f8c2533c 100644 --- a/shell/hush_test/hush-misc/control_char1.right +++ b/shell/hush_test/hush-misc/control_char1.right | |||
@@ -1,2 +1,3 @@ | |||
1 | 1 | ||
2 | b#c | ||
2 | Done:0 | 3 | Done:0 |
diff --git a/shell/hush_test/hush-misc/control_char1.tests b/shell/hush_test/hush-misc/control_char1.tests index a2ebeba1b..0cfe60141 100755 --- a/shell/hush_test/hush-misc/control_char1.tests +++ b/shell/hush_test/hush-misc/control_char1.tests | |||
@@ -1,2 +1,3 @@ | |||
1 | echo | 1 | echo |
2 | echo 'b#c' | ||
2 | echo Done:$? | 3 | echo Done:$? |
diff --git a/shell/hush_test/hush-misc/for_with_bslashes.right b/shell/hush_test/hush-misc/for_with_bslashes.right index 02d96692c..cd8501050 100644 --- a/shell/hush_test/hush-misc/for_with_bslashes.right +++ b/shell/hush_test/hush-misc/for_with_bslashes.right | |||
@@ -5,4 +5,5 @@ b"c | |||
5 | b'c | 5 | b'c |
6 | b$c | 6 | b$c |
7 | b`true`c | 7 | b`true`c |
8 | b#c | ||
8 | Zero:0 | 9 | Zero:0 |
diff --git a/shell/hush_test/hush-misc/for_with_bslashes.tests b/shell/hush_test/hush-misc/for_with_bslashes.tests index 363f3d85b..8acd9808a 100755 --- a/shell/hush_test/hush-misc/for_with_bslashes.tests +++ b/shell/hush_test/hush-misc/for_with_bslashes.tests | |||
@@ -1,9 +1,5 @@ | |||
1 | # UNFIXED BUG. | 1 | # last word contains ^C character. |
2 | # commented-out words contain ^C character. | 2 | for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' 'b#c' |
3 | # It's a SPECIAL_VAR_SYMBOL, for now hush does not escape it. | ||
4 | # When it is fixed, update this test. | ||
5 | |||
6 | for a in 'a' 'b\c' 'b\\c' 'b"c' "b'c" 'b$c' 'b`true`c' ### 'b#c' | ||
7 | do | 3 | do |
8 | echo $a | 4 | echo $a |
9 | done | 5 | done |