aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test/ash-vars
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 18:08:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-02 18:08:04 +0200
commite3354bc44aa92c20bec0ffdc78e6b57351e8f16d (patch)
tree5b1d0397af69b7bcd9f63d94705cfdbade01810a /shell/ash_test/ash-vars
parentc4cf542c575068d55368e771abf6c358bfebf5d3 (diff)
downloadbusybox-e3354bc44aa92c20bec0ffdc78e6b57351e8f16d.tar.gz
ash testsuite: update some of variable tests with newer versions from hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test/ash-vars')
-rw-r--r--shell/ash_test/ash-vars/var_bash4.right25
-rwxr-xr-xshell/ash_test/ash-vars/var_bash4.tests52
-rw-r--r--shell/ash_test/ash-vars/var_bash5.right13
-rwxr-xr-xshell/ash_test/ash-vars/var_bash5.tests24
-rw-r--r--shell/ash_test/ash-vars/var_posix1.right30
-rwxr-xr-xshell/ash_test/ash-vars/var_posix1.tests37
6 files changed, 156 insertions, 25 deletions
diff --git a/shell/ash_test/ash-vars/var_bash4.right b/shell/ash_test/ash-vars/var_bash4.right
index 600e8532f..0ef1bf661 100644
--- a/shell/ash_test/ash-vars/var_bash4.right
+++ b/shell/ash_test/ash-vars/var_bash4.right
@@ -1,23 +1,40 @@
Source: a*b\*c
Replace str: _\\_\z_
Pattern: single backslash and star: "replace literal star"
-In assignment: a_\_z_b\*c
Unquoted: a_\_z_b\*c
+Unquoted =: a_\_z_b\*c
Quoted: a_\_\z_b\*c
+Quoted =: a_\_\z_b\*c
Pattern: double backslash and star: "replace backslash and everything after it"
-In assignment: a*b_\_z_
Unquoted: a*b_\_z_
+Unquoted =: a*b_\_z_
Quoted: a*b_\_\z_
+Quoted =: a*b_\_\z_
Source: a\bc
Replace str: _\\_\z_
Pattern: single backslash and b: "replace b"
-In assignment: a\_\_z_c
Unquoted: a\_\_z_c
+Unquoted =: a\_\_z_c
Quoted: a\_\_\z_c
+Quoted =: a\_\_\z_c
Pattern: double backslash and b: "replace backslash and b"
-In assignment: a_\_z_c
Unquoted: a_\_z_c
+Unquoted =: a_\_z_c
Quoted: a_\_\z_c
+Quoted =: a_\_\z_c
+
+Source: a\bc
+Replace str: _\\_\z_ (as variable $s)
+Pattern: single backslash and b: "replace b"
+Unquoted: a\_\\_\z_c
+Unquoted =: a\_\\_\z_c
+Quoted: a\_\\_\z_c
+Quoted =: a\_\\_\z_c
+Pattern: double backslash and b: "replace backslash and b"
+Unquoted: a_\\_\z_c
+Unquoted =: a_\\_\z_c
+Quoted: a_\\_\z_c
+Quoted =: a_\\_\z_c
Done: 0
diff --git a/shell/ash_test/ash-vars/var_bash4.tests b/shell/ash_test/ash-vars/var_bash4.tests
index d5470614b..32aa2b34c 100755
--- a/shell/ash_test/ash-vars/var_bash4.tests
+++ b/shell/ash_test/ash-vars/var_bash4.tests
@@ -6,23 +6,30 @@
# even in quotes.
#
# bash4 (and probably bash3 too): "Quoted:" results are different from
-# unquoted and assignment expansions - they have a backslash before z.
+# unquoted expansions - they have a backslash before z.
+#
+# The difference only exists if repl is a literal. If it is a variable:
+# ${v/.../$s}, then all backslashes are preserved in both cases.
v='a*b\*c'
echo 'Source: ' "$v"
echo 'Replace str: ' '_\\_\z_'
echo 'Pattern: ' 'single backslash and star: "replace literal star"'
-r=${v/\*/_\\_\z_}
-echo 'In assignment:' "$r"
echo 'Unquoted: ' ${v/\*/_\\_\z_}
+r=${v/\*/_\\_\z_}
+echo 'Unquoted =: ' "$r"
echo 'Quoted: ' "${v/\*/_\\_\z_}"
+r="${v/\*/_\\_\z_}"
+echo 'Quoted =: ' "$r"
echo 'Pattern: ' 'double backslash and star: "replace backslash and everything after it"'
-r=${v/\\*/_\\_\z_}
-echo 'In assignment:' "$r"
echo 'Unquoted: ' ${v/\\*/_\\_\z_}
+r=${v/\\*/_\\_\z_}
+echo 'Unquoted =: ' "$r"
echo 'Quoted: ' "${v/\\*/_\\_\z_}"
+r="${v/\\*/_\\_\z_}"
+echo 'Quoted =: ' "$r"
echo
@@ -31,16 +38,43 @@ echo 'Source: ' "$v"
echo 'Replace str: ' '_\\_\z_'
echo 'Pattern: ' 'single backslash and b: "replace b"'
-r=${v/\b/_\\_\z_}
-echo 'In assignment:' "$r"
echo 'Unquoted: ' ${v/\b/_\\_\z_}
+r=${v/\b/_\\_\z_}
+echo 'Unquoted =: ' "$r"
echo 'Quoted: ' "${v/\b/_\\_\z_}"
+r="${v/\b/_\\_\z_}"
+echo 'Quoted =: ' "$r"
echo 'Pattern: ' 'double backslash and b: "replace backslash and b"'
-r=${v/\\b/_\\_\z_}
-echo 'In assignment:' "$r"
echo 'Unquoted: ' ${v/\\b/_\\_\z_}
+r=${v/\\b/_\\_\z_}
+echo 'Unquoted =: ' "$r"
echo 'Quoted: ' "${v/\\b/_\\_\z_}"
+r="${v/\\b/_\\_\z_}"
+echo 'Quoted =: ' "$r"
+
+echo
+
+v='a\bc'
+s='_\\_\z_'
+echo 'Source: ' "$v"
+echo 'Replace str: ' "$s" '(as variable $s)'
+
+echo 'Pattern: ' 'single backslash and b: "replace b"'
+echo 'Unquoted: ' ${v/\b/$s}
+r=${v/\b/$s}
+echo 'Unquoted =: ' "$r"
+echo 'Quoted: ' "${v/\b/$s}"
+r="${v/\b/$s}"
+echo 'Quoted =: ' "$r"
+
+echo 'Pattern: ' 'double backslash and b: "replace backslash and b"'
+echo 'Unquoted: ' ${v/\\b/$s}
+r=${v/\\b/$s}
+echo 'Unquoted =: ' "$r"
+echo 'Quoted: ' "${v/\\b/$s}"
+r="${v/\\b/$s}"
+echo 'Quoted =: ' "$r"
echo
diff --git a/shell/ash_test/ash-vars/var_bash5.right b/shell/ash_test/ash-vars/var_bash5.right
index 278ed3228..1990902b2 100644
--- a/shell/ash_test/ash-vars/var_bash5.right
+++ b/shell/ash_test/ash-vars/var_bash5.right
@@ -1,4 +1,11 @@
-a/
-a/d
-a/e/f
+1 a/
+2 a/d
+3 a/e/f
+4 a\
+5 a\d
+6 a\e\f
+7 a\\
+8 a\\d
+9 a\\e\\f
+a ab
Done: 0
diff --git a/shell/ash_test/ash-vars/var_bash5.tests b/shell/ash_test/ash-vars/var_bash5.tests
index 7f482a554..5748b4ac7 100755
--- a/shell/ash_test/ash-vars/var_bash5.tests
+++ b/shell/ash_test/ash-vars/var_bash5.tests
@@ -4,8 +4,26 @@
v='a/b/c'
s='b/c'
r='e/f'
-echo "${v/$s}"
-echo "${v/$s/d}"
-echo "${v/$s/$r}"
+echo "1 ${v/$s}"
+echo "2 ${v/$s/d}"
+echo "3 ${v/$s/$r}"
+
+v='a\b\c'
+s='b\\c'
+r='e\f'
+echo "4 ${v/$s}"
+echo "5 ${v/$s/d}"
+echo "6 ${v/$s/$r}"
+
+v='a\\b\\c'
+s='b\\\\c'
+r='e\\f'
+echo "7 ${v/$s}"
+echo "8 ${v/$s/d}"
+echo "9 ${v/$s/$r}"
+
+v='a-$a-\t-\\-\"-\`-\--\z-\*-\?-b'
+s='-$a-\\t-\\\\-\\"-\\`-\\--\\z-\\\*-\\\?-'
+echo "a ${v/$s}"
echo Done: $?
diff --git a/shell/ash_test/ash-vars/var_posix1.right b/shell/ash_test/ash-vars/var_posix1.right
index 55f35798a..7ff618ad0 100644
--- a/shell/ash_test/ash-vars/var_posix1.right
+++ b/shell/ash_test/ash-vars/var_posix1.right
@@ -1,3 +1,19 @@
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
+Empty:
abcdcd
abcdcd
abcdcd
@@ -5,7 +21,9 @@ cdcd
babcdcd
babcdcd
ababcdcd
-
+Empty:
+ababcdcd}_tail
+ababcdcd_tail
ababcd
ababcd
ababcd
@@ -13,5 +31,11 @@ abab
ababcdc
ababcdc
ababcdcd
-
-end
+Empty:
+ababcdcd}_tail
+ababcdcd_tail
+ababcdcd
+ab
+ab
+ab
+End
diff --git a/shell/ash_test/ash-vars/var_posix1.tests b/shell/ash_test/ash-vars/var_posix1.tests
index 4139e2cc3..82abe8198 100755
--- a/shell/ash_test/ash-vars/var_posix1.tests
+++ b/shell/ash_test/ash-vars/var_posix1.tests
@@ -1,3 +1,25 @@
+unset var
+
+echo Empty:${var#}
+echo Empty:${var##}
+echo Empty:${var#*}
+echo Empty:${var##*}
+echo Empty:${var%}
+echo Empty:${var%%}
+echo Empty:${var%*}
+echo Empty:${var%%*}
+
+var=
+
+echo Empty:${var#}
+echo Empty:${var##}
+echo Empty:${var#*}
+echo Empty:${var##*}
+echo Empty:${var%}
+echo Empty:${var%%}
+echo Empty:${var%*}
+echo Empty:${var%%*}
+
var=ababcdcd
echo ${var#ab}
@@ -7,7 +29,9 @@ echo ${var##a*b}
echo ${var#?}
echo ${var##?}
echo ${var#*}
-echo ${var##*}
+echo Empty:${var##*}
+echo ${var#}}_tail
+echo ${var#\}}_tail
echo ${var%cd}
echo ${var%%cd}
@@ -16,6 +40,13 @@ echo ${var%%c*d}
echo ${var%?}
echo ${var%%?}
echo ${var%*}
-echo ${var%%*}
+echo Empty:${var%%*}
+echo ${var#}}_tail
+echo ${var#\}}_tail
+echo ${var%\\*}
+
+a=ab}; echo ${a%\}};
+a=abc; c=c; echo ${a%${c}}
+a=ab{{c; echo ${a%`echo {{c`}
-echo end
+echo End