aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-08-06 17:21:52 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-06 17:21:52 +0200
commitf56fe8254274cea34d2550870c2dfc010bdfa7e8 (patch)
tree726d1d6fbc5c1c01b74c6a3fd1b8687b97b9bd5b
parent95b83ba4f81f0985e2aeb9aec9cd67db7d5d1126 (diff)
downloadbusybox-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.right25
-rwxr-xr-xshell/ash_test/ash-vars/var_bash4.tests51
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 @@
1In assignment: a*b-backslashstar- 1Source: a*b\*c
2Unquoted: a*b-backslashstar- 2Replace str: _\\_\z_
3Quoted: a*b-backslashstar- 3Pattern: single backslash and star: "replace literal star"
4In assignment: a_\_z_b\*c
5Unquoted: a_\_z_b\*c
6Quoted: a_\_\z_b\*c
7Pattern: double backslash and star: "replace backslash and everything after it"
8In assignment: a*b_\_z_
9Unquoted: a*b_\_z_
10Quoted: a*b_\_\z_
11
12Source: a\bc
13Replace str: _\\_\z_
14Pattern: single backslash and b: "replace literal b"
15In assignment: a\_\_z_c
16Unquoted: a\_\_z_c
17Quoted: a\_\_\z_c
18Pattern: double backslash and b: "replace backslash and b"
19In assignment: a_\_z_c
20Unquoted: a_\_z_c
21Quoted: a_\_\z_c
22
4Done: 0 23Done: 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 @@
1FOO='a*b\*c' 1# This testcase demonstrates that backslashes are treated differently
2BAR=${FOO//\\*/-backslashstar-} 2# in 1st and 2nd parts of ${var/search/repl}:
3echo In assignment: "$BAR" 3# if quoted: "${var/search/repl}", and repl contains \a (a non-special char),
4echo Unquoted: ${FOO//\\*/-backslashstar-} 4# the backslash in repl stays; if unquoted, backslash: removed
5echo 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
11v='a*b\*c'
12echo 'Source: ' "$v"
13echo 'Replace str: ' '_\\_\z_'
14
15echo 'Pattern: ' 'single backslash and star: "replace literal star"'
16r=${v/\*/_\\_\z_}
17echo 'In assignment:' "$r"
18echo 'Unquoted: ' ${v/\*/_\\_\z_}
19echo 'Quoted: ' "${v/\*/_\\_\z_}"
20
21echo 'Pattern: ' 'double backslash and star: "replace backslash and everything after it"'
22r=${v/\\*/_\\_\z_}
23echo 'In assignment:' "$r"
24echo 'Unquoted: ' ${v/\\*/_\\_\z_}
25echo 'Quoted: ' "${v/\\*/_\\_\z_}"
26
27echo
28
29v='a\bc'
30echo 'Source: ' "$v"
31echo 'Replace str: ' '_\\_\z_'
32
33echo 'Pattern: ' 'single backslash and b: "replace literal b"'
34r=${v/\b/_\\_\z_}
35echo 'In assignment:' "$r"
36echo 'Unquoted: ' ${v/\b/_\\_\z_}
37echo 'Quoted: ' "${v/\b/_\\_\z_}"
38
39echo 'Pattern: ' 'double backslash and b: "replace backslash and b"'
40r=${v/\\b/_\\_\z_}
41echo 'In assignment:' "$r"
42echo 'Unquoted: ' ${v/\\b/_\\_\z_}
43echo 'Quoted: ' "${v/\\b/_\\_\z_}"
44
45echo
46
6echo Done: $? 47echo Done: $?