diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-06 17:21:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-06 17:21:52 +0200 |
commit | f56fe8254274cea34d2550870c2dfc010bdfa7e8 (patch) | |
tree | 726d1d6fbc5c1c01b74c6a3fd1b8687b97b9bd5b | |
parent | 95b83ba4f81f0985e2aeb9aec9cd67db7d5d1126 (diff) | |
download | busybox-w32-f56fe8254274cea34d2550870c2dfc010bdfa7e8.tar.gz busybox-w32-f56fe8254274cea34d2550870c2dfc010bdfa7e8.tar.bz2 busybox-w32-f56fe8254274cea34d2550870c2dfc010bdfa7e8.zip |
update var_bash4 test. one more bug revealed by it now...
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash_test/ash-vars/var_bash4.right | 25 | ||||
-rwxr-xr-x | shell/ash_test/ash-vars/var_bash4.tests | 51 |
2 files changed, 68 insertions, 8 deletions
diff --git a/shell/ash_test/ash-vars/var_bash4.right b/shell/ash_test/ash-vars/var_bash4.right index fc3a9e41c..2d4e45be8 100644 --- a/shell/ash_test/ash-vars/var_bash4.right +++ b/shell/ash_test/ash-vars/var_bash4.right | |||
@@ -1,4 +1,23 @@ | |||
1 | In assignment: a*b-backslashstar- | 1 | Source: a*b\*c |
2 | Unquoted: a*b-backslashstar- | 2 | Replace str: _\\_\z_ |
3 | Quoted: a*b-backslashstar- | 3 | Pattern: single backslash and star: "replace literal star" |
4 | In assignment: a_\_z_b\*c | ||
5 | Unquoted: a_\_z_b\*c | ||
6 | Quoted: a_\_\z_b\*c | ||
7 | Pattern: double backslash and star: "replace backslash and everything after it" | ||
8 | In assignment: a*b_\_z_ | ||
9 | Unquoted: a*b_\_z_ | ||
10 | Quoted: a*b_\_\z_ | ||
11 | |||
12 | Source: a\bc | ||
13 | Replace str: _\\_\z_ | ||
14 | Pattern: single backslash and b: "replace literal b" | ||
15 | In assignment: a\_\_z_c | ||
16 | Unquoted: a\_\_z_c | ||
17 | Quoted: a\_\_\z_c | ||
18 | Pattern: double backslash and b: "replace backslash and b" | ||
19 | In assignment: a_\_z_c | ||
20 | Unquoted: a_\_z_c | ||
21 | Quoted: a_\_\z_c | ||
22 | |||
4 | Done: 0 | 23 | Done: 0 |
diff --git a/shell/ash_test/ash-vars/var_bash4.tests b/shell/ash_test/ash-vars/var_bash4.tests index 3b323c576..01a0def51 100755 --- a/shell/ash_test/ash-vars/var_bash4.tests +++ b/shell/ash_test/ash-vars/var_bash4.tests | |||
@@ -1,6 +1,47 @@ | |||
1 | FOO='a*b\*c' | 1 | # This testcase demonstrates that backslashes are treated differently |
2 | BAR=${FOO//\\*/-backslashstar-} | 2 | # in 1st and 2nd parts of ${var/search/repl}: |
3 | echo In assignment: "$BAR" | 3 | # if quoted: "${var/search/repl}", and repl contains \a (a non-special char), |
4 | echo Unquoted: ${FOO//\\*/-backslashstar-} | 4 | # the backslash in repl stays; if unquoted, backslash: removed |
5 | echo Quoted: "${FOO//\\*/-backslashstar-}" | 5 | # But search part does not act like that: \a is always converted to just a, |
6 | # even in quotes. | ||
7 | # | ||
8 | # bash4 (and probably bash3 too) result: "Quoted:" results are different - | ||
9 | # they have extra backslash before z. | ||
10 | |||
11 | v='a*b\*c' | ||
12 | echo 'Source: ' "$v" | ||
13 | echo 'Replace str: ' '_\\_\z_' | ||
14 | |||
15 | echo 'Pattern: ' 'single backslash and star: "replace literal star"' | ||
16 | r=${v/\*/_\\_\z_} | ||
17 | echo 'In assignment:' "$r" | ||
18 | echo 'Unquoted: ' ${v/\*/_\\_\z_} | ||
19 | echo 'Quoted: ' "${v/\*/_\\_\z_}" | ||
20 | |||
21 | echo 'Pattern: ' 'double backslash and star: "replace backslash and everything after it"' | ||
22 | r=${v/\\*/_\\_\z_} | ||
23 | echo 'In assignment:' "$r" | ||
24 | echo 'Unquoted: ' ${v/\\*/_\\_\z_} | ||
25 | echo 'Quoted: ' "${v/\\*/_\\_\z_}" | ||
26 | |||
27 | echo | ||
28 | |||
29 | v='a\bc' | ||
30 | echo 'Source: ' "$v" | ||
31 | echo 'Replace str: ' '_\\_\z_' | ||
32 | |||
33 | echo 'Pattern: ' 'single backslash and b: "replace literal b"' | ||
34 | r=${v/\b/_\\_\z_} | ||
35 | echo 'In assignment:' "$r" | ||
36 | echo 'Unquoted: ' ${v/\b/_\\_\z_} | ||
37 | echo 'Quoted: ' "${v/\b/_\\_\z_}" | ||
38 | |||
39 | echo 'Pattern: ' 'double backslash and b: "replace backslash and b"' | ||
40 | r=${v/\\b/_\\_\z_} | ||
41 | echo 'In assignment:' "$r" | ||
42 | echo 'Unquoted: ' ${v/\\b/_\\_\z_} | ||
43 | echo 'Quoted: ' "${v/\\b/_\\_\z_}" | ||
44 | |||
45 | echo | ||
46 | |||
6 | echo Done: $? | 47 | echo Done: $? |