ash testsuite: update some of variable tests with newer versions from hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
c4cf542c57
commit
e3354bc44a
@ -1,23 +1,40 @@
|
|||||||
Source: a*b\*c
|
Source: a*b\*c
|
||||||
Replace str: _\\_\z_
|
Replace str: _\\_\z_
|
||||||
Pattern: single backslash and star: "replace literal star"
|
Pattern: single backslash and star: "replace literal star"
|
||||||
In assignment: a_\_z_b\*c
|
|
||||||
Unquoted: a_\_z_b\*c
|
Unquoted: a_\_z_b\*c
|
||||||
|
Unquoted =: a_\_z_b\*c
|
||||||
Quoted: 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"
|
Pattern: double backslash and star: "replace backslash and everything after it"
|
||||||
In assignment: a*b_\_z_
|
|
||||||
Unquoted: a*b_\_z_
|
Unquoted: a*b_\_z_
|
||||||
|
Unquoted =: a*b_\_z_
|
||||||
Quoted: a*b_\_\z_
|
Quoted: a*b_\_\z_
|
||||||
|
Quoted =: a*b_\_\z_
|
||||||
|
|
||||||
Source: a\bc
|
Source: a\bc
|
||||||
Replace str: _\\_\z_
|
Replace str: _\\_\z_
|
||||||
Pattern: single backslash and b: "replace b"
|
Pattern: single backslash and b: "replace b"
|
||||||
In assignment: a\_\_z_c
|
|
||||||
Unquoted: a\_\_z_c
|
Unquoted: a\_\_z_c
|
||||||
|
Unquoted =: a\_\_z_c
|
||||||
Quoted: a\_\_\z_c
|
Quoted: a\_\_\z_c
|
||||||
|
Quoted =: a\_\_\z_c
|
||||||
Pattern: double backslash and b: "replace backslash and b"
|
Pattern: double backslash and b: "replace backslash and b"
|
||||||
In assignment: a_\_z_c
|
|
||||||
Unquoted: a_\_z_c
|
Unquoted: a_\_z_c
|
||||||
|
Unquoted =: a_\_z_c
|
||||||
Quoted: 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
|
Done: 0
|
||||||
|
@ -6,23 +6,30 @@
|
|||||||
# even in quotes.
|
# even in quotes.
|
||||||
#
|
#
|
||||||
# bash4 (and probably bash3 too): "Quoted:" results are different from
|
# 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'
|
v='a*b\*c'
|
||||||
echo 'Source: ' "$v"
|
echo 'Source: ' "$v"
|
||||||
echo 'Replace str: ' '_\\_\z_'
|
echo 'Replace str: ' '_\\_\z_'
|
||||||
|
|
||||||
echo 'Pattern: ' 'single backslash and star: "replace literal star"'
|
echo 'Pattern: ' 'single backslash and star: "replace literal star"'
|
||||||
r=${v/\*/_\\_\z_}
|
|
||||||
echo 'In assignment:' "$r"
|
|
||||||
echo 'Unquoted: ' ${v/\*/_\\_\z_}
|
echo 'Unquoted: ' ${v/\*/_\\_\z_}
|
||||||
|
r=${v/\*/_\\_\z_}
|
||||||
|
echo 'Unquoted =: ' "$r"
|
||||||
echo 'Quoted: ' "${v/\*/_\\_\z_}"
|
echo 'Quoted: ' "${v/\*/_\\_\z_}"
|
||||||
|
r="${v/\*/_\\_\z_}"
|
||||||
|
echo 'Quoted =: ' "$r"
|
||||||
|
|
||||||
echo 'Pattern: ' 'double backslash and star: "replace backslash and everything after it"'
|
echo 'Pattern: ' 'double backslash and star: "replace backslash and everything after it"'
|
||||||
r=${v/\\*/_\\_\z_}
|
|
||||||
echo 'In assignment:' "$r"
|
|
||||||
echo 'Unquoted: ' ${v/\\*/_\\_\z_}
|
echo 'Unquoted: ' ${v/\\*/_\\_\z_}
|
||||||
|
r=${v/\\*/_\\_\z_}
|
||||||
|
echo 'Unquoted =: ' "$r"
|
||||||
echo 'Quoted: ' "${v/\\*/_\\_\z_}"
|
echo 'Quoted: ' "${v/\\*/_\\_\z_}"
|
||||||
|
r="${v/\\*/_\\_\z_}"
|
||||||
|
echo 'Quoted =: ' "$r"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -31,16 +38,43 @@ echo 'Source: ' "$v"
|
|||||||
echo 'Replace str: ' '_\\_\z_'
|
echo 'Replace str: ' '_\\_\z_'
|
||||||
|
|
||||||
echo 'Pattern: ' 'single backslash and b: "replace b"'
|
echo 'Pattern: ' 'single backslash and b: "replace b"'
|
||||||
r=${v/\b/_\\_\z_}
|
|
||||||
echo 'In assignment:' "$r"
|
|
||||||
echo 'Unquoted: ' ${v/\b/_\\_\z_}
|
echo 'Unquoted: ' ${v/\b/_\\_\z_}
|
||||||
|
r=${v/\b/_\\_\z_}
|
||||||
|
echo 'Unquoted =: ' "$r"
|
||||||
echo 'Quoted: ' "${v/\b/_\\_\z_}"
|
echo 'Quoted: ' "${v/\b/_\\_\z_}"
|
||||||
|
r="${v/\b/_\\_\z_}"
|
||||||
|
echo 'Quoted =: ' "$r"
|
||||||
|
|
||||||
echo 'Pattern: ' 'double backslash and b: "replace backslash and b"'
|
echo 'Pattern: ' 'double backslash and b: "replace backslash and b"'
|
||||||
r=${v/\\b/_\\_\z_}
|
|
||||||
echo 'In assignment:' "$r"
|
|
||||||
echo 'Unquoted: ' ${v/\\b/_\\_\z_}
|
echo 'Unquoted: ' ${v/\\b/_\\_\z_}
|
||||||
|
r=${v/\\b/_\\_\z_}
|
||||||
|
echo 'Unquoted =: ' "$r"
|
||||||
echo 'Quoted: ' "${v/\\b/_\\_\z_}"
|
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
|
echo
|
||||||
|
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
a/
|
1 a/
|
||||||
a/d
|
2 a/d
|
||||||
a/e/f
|
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
|
Done: 0
|
||||||
|
@ -4,8 +4,26 @@
|
|||||||
v='a/b/c'
|
v='a/b/c'
|
||||||
s='b/c'
|
s='b/c'
|
||||||
r='e/f'
|
r='e/f'
|
||||||
echo "${v/$s}"
|
echo "1 ${v/$s}"
|
||||||
echo "${v/$s/d}"
|
echo "2 ${v/$s/d}"
|
||||||
echo "${v/$s/$r}"
|
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: $?
|
echo Done: $?
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
|
Empty:
|
||||||
abcdcd
|
abcdcd
|
||||||
abcdcd
|
abcdcd
|
||||||
abcdcd
|
abcdcd
|
||||||
@ -5,7 +21,9 @@ cdcd
|
|||||||
babcdcd
|
babcdcd
|
||||||
babcdcd
|
babcdcd
|
||||||
ababcdcd
|
ababcdcd
|
||||||
|
Empty:
|
||||||
|
ababcdcd}_tail
|
||||||
|
ababcdcd_tail
|
||||||
ababcd
|
ababcd
|
||||||
ababcd
|
ababcd
|
||||||
ababcd
|
ababcd
|
||||||
@ -13,5 +31,11 @@ abab
|
|||||||
ababcdc
|
ababcdc
|
||||||
ababcdc
|
ababcdc
|
||||||
ababcdcd
|
ababcdcd
|
||||||
|
Empty:
|
||||||
end
|
ababcdcd}_tail
|
||||||
|
ababcdcd_tail
|
||||||
|
ababcdcd
|
||||||
|
ab
|
||||||
|
ab
|
||||||
|
ab
|
||||||
|
End
|
||||||
|
@ -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
|
var=ababcdcd
|
||||||
|
|
||||||
echo ${var#ab}
|
echo ${var#ab}
|
||||||
@ -7,7 +29,9 @@ echo ${var##a*b}
|
|||||||
echo ${var#?}
|
echo ${var#?}
|
||||||
echo ${var##?}
|
echo ${var##?}
|
||||||
echo ${var#*}
|
echo ${var#*}
|
||||||
echo ${var##*}
|
echo Empty:${var##*}
|
||||||
|
echo ${var#}}_tail
|
||||||
|
echo ${var#\}}_tail
|
||||||
|
|
||||||
echo ${var%cd}
|
echo ${var%cd}
|
||||||
echo ${var%%cd}
|
echo ${var%%cd}
|
||||||
@ -16,6 +40,13 @@ echo ${var%%c*d}
|
|||||||
echo ${var%?}
|
echo ${var%?}
|
||||||
echo ${var%%?}
|
echo ${var%%?}
|
||||||
echo ${var%*}
|
echo ${var%*}
|
||||||
echo ${var%%*}
|
echo Empty:${var%%*}
|
||||||
|
echo ${var#}}_tail
|
||||||
|
echo ${var#\}}_tail
|
||||||
|
echo ${var%\\*}
|
||||||
|
|
||||||
echo end
|
a=ab}; echo ${a%\}};
|
||||||
|
a=abc; c=c; echo ${a%${c}}
|
||||||
|
a=ab{{c; echo ${a%`echo {{c`}
|
||||||
|
|
||||||
|
echo End
|
||||||
|
Loading…
Reference in New Issue
Block a user