aboutsummaryrefslogtreecommitdiff
path: root/tests/sh.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-10-04 02:07:49 -0500
committerRob Landley <rob@landley.net>2020-10-04 02:07:49 -0500
commitce683cdce2629721339f526c5059af9b3042958e (patch)
tree3a55674063a5bcd2f5fc3c6344cdd4bf0473b927 /tests/sh.test
parent07c316a2bbf0ad0f41229ca668def609a5f50f2c (diff)
downloadtoybox-ce683cdce2629721339f526c5059af9b3042958e.tar.gz
Implement ${x#y} and ${x##y}
Debug wildcard * match, teach skipslash() to fill out a wildcard deck, make collect_wildcards() flush remove the parsing-only 0th entry.
Diffstat (limited to 'tests/sh.test')
-rw-r--r--tests/sh.test7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/sh.test b/tests/sh.test
index 1adbd97f..f0764858 100644
--- a/tests/sh.test
+++ b/tests/sh.test
@@ -163,6 +163,13 @@ testing "brackets9" 'echo A{B{C,D}E{N,O},F{G,H}I}J{K,L}M' \
for i in /root /var/root /; do [ -e $i ] && EXPECT=$i && break; done
testing "bracket+tilde" "echo {~,~root}/pwd" "$HOME/pwd $EXPECT/pwd\n" "" ""
+# Slices
+
+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 "backtick1" 'X=fred; echo `echo $x`' 'fred\n' "" ""
#testing "backtick2" 'X=fred; echo `x=y; echo $x`' 'y\n' "" ""
testing '$(( ) )' 'echo ab$((echo hello) | tr e x)cd' "abhxllocd\n" "" ""