From 114f415ca15daaf3e491161885513812eba5b2fc Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 13 Oct 2020 02:20:49 -0500 Subject: Fix up ${x%y} ${x^y} ${x,y} and add tests. --- tests/sh.test | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests') 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' \ -- cgit v1.2.3