From ce683cdce2629721339f526c5059af9b3042958e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 4 Oct 2020 02:07:49 -0500 Subject: 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. --- tests/sh.test | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/sh.test') 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" "" "" -- cgit v1.2.3