From d2241f59022c38d4b171e56eea42e216ecccfdd9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 31 Oct 2020 03:34:07 +0100 Subject: shell: better support of [[ ]] bashism Still rather rudimentary for ash function old new delta binop 433 589 +156 check_operator 65 101 +36 done_word 736 769 +33 test_main 405 418 +13 parse_stream 2227 2238 +11 ops_texts 124 133 +9 ops_table 80 86 +6 run_pipe 1557 1562 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 269/0) Total: 269 bytes Signed-off-by: Denys Vlasenko --- shell/hush_test/hush-test2/strops3.tests | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 shell/hush_test/hush-test2/strops3.tests (limited to 'shell/hush_test/hush-test2/strops3.tests') diff --git a/shell/hush_test/hush-test2/strops3.tests b/shell/hush_test/hush-test2/strops3.tests new file mode 100755 index 000000000..927476671 --- /dev/null +++ b/shell/hush_test/hush-test2/strops3.tests @@ -0,0 +1,13 @@ +# regex should accept '+' operator +[[ abcdef =~ a[b-z]+ ]]; echo 1:YES:$? + +# newline matches by "match any" patterns +v=' +' +[[ "$v" =~ . ]]; echo 2:YES:$? +[[ "$v" =~ "[$v]" ]]; echo 3:no:$? # hmm bash does return 1... why? +[[ "$v" =~ [^a] ]]; echo 4:YES:$? +# should work even without quotes: +[[ $v =~ . ]]; echo 2u:YES:$? +[[ $v =~ [$v] ]]; echo 3u:YES:$? +[[ $v =~ [^a] ]]; echo 4u:YES:$? -- cgit v1.2.3