aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-10-13 02:20:49 -0500
committerRob Landley <rob@landley.net>2020-10-13 02:20:49 -0500
commit114f415ca15daaf3e491161885513812eba5b2fc (patch)
tree32429ae8d966a9c2f8a62c97bbaf22bfc5ea63cc /tests
parentb61876564c2977a2d776b26dc7a2dcf28ed00bb7 (diff)
downloadtoybox-114f415ca15daaf3e491161885513812eba5b2fc.tar.gz
Fix up ${x%y} ${x^y} ${x,y} and add tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/sh.test10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/sh.test b/tests/sh.test
index b095bb95..516e0c82 100644
--- a/tests/sh.test
+++ b/tests/sh.test
@@ -9,7 +9,7 @@
# Looked like a prefix but wasn't: three chars (@ # -) are both paremeter name
# and slice operator. When immediately followed by } it's parameter, otherwise
-# otherwise we did NOT have a prefix and it's an operator.
+# we did NOT have a prefix and it's an operator.
#
# ${#-} ${#-abc}
# ${##} ${##0}
@@ -173,6 +173,14 @@ testing '${x#prefix}' 'x=abcde; echo ${x#abc}' 'de\n' '' ''
testing '${x#short} ${x##long}' 'x=banana; echo ${x#b*n} ${x##b*n}' \
'ana a\n' '' ''
toyonly testing '${x#utf8}' 'x=aそcde; echo ${x##a?c}' 'de\n' '' ''
+testing '${x%y}' 'x=potato; echo ${x%t*o} ${x%%t*o}' 'pota po\n' '' ''
+testing '${x^y}' 'x=aaaaa; echo ${x^a}' 'Aaaaa\n' '' ''
+testing '${x^^y}' 'x=abccdec; echo ${x^^c}; x=abcdec; echo ${x^^c}' \
+ 'abCCdeC\nabCdeC\n' '' ''
+testing '${x,y}' 'x=BBB; echo ${x,B}' 'bBB\n' '' ''
+testing '${x,,y}' 'x=POTATO; echo ${x,,} ${x,,?} ${x,,*} ${x,,T}' \
+ 'potato potato potato POtAtO\n' '' ''
+
mkdir -p abc/def/ghi
touch www
testing 'wildcards' 'echo w[v-x]w w[x-v]w abc/*/ghi' \