diff options
author | Aaron Gyes <me@aaron.gy> | 2016-04-08 10:18:58 +0800 |
---|---|---|
committer | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2016-04-08 10:49:29 +0800 |
commit | 790c7f80c7d0fa1c97380885201eb50a2abcce02 (patch) | |
tree | 71e525e03cb4dee3a0be8f18fd76ac35c0e2a7f9 /tests | |
parent | 155befe90e2e9e2ab022e81f5f3661bed3c8c9e9 (diff) |
Implement an --invert/-v for string match, like grep -v.
Only lines that do not match the pattern are shown.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/string.in | 25 | ||||
-rw-r--r-- | tests/string.out | 17 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/string.in b/tests/string.in index 8afc97ff..ac858618 100644 --- a/tests/string.in +++ b/tests/string.in @@ -1,5 +1,26 @@ # tests for string builtin # mostly taken from examples + +string match -r -v "c.*" dog can cat diz; and echo "exit 0" + +string match -q -r -v "c.*" dog can cat diz; and echo "exit 0" + +string match -v "c*" dog can cat diz; and echo "exit 0" + +string match -q -v "c*" dog can cat diz; and echo "exit 0" + +string match -v "d*" dog dan dat diz; or echo "exit 1" + +string match -q -v "d*" dog dan dat diz; or echo "exit 1" + +string match -r -v x y; and echo "exit 0" + +string match -r -v x x; or echo "exit 1" + +string match -q -r -v x y; and echo "exit 0" + +string match -q -r -v x x; or echo "exit 1" + string length 'hello, world' string length -q ""; and echo not zero length @@ -63,3 +84,7 @@ string match -r '[' 'a[sd' 2>/dev/null; or echo "invalid expression error" string invalidarg 2>/dev/null; or echo "invalid argument error" string length 2>/dev/null; or echo "missing argument returns 0" + +string match -r -v "[dcantg].*" dog can cat diz; or echo "no regexp invert match" + +string match -v "???" dog can cat diz; or echo "no glob invert match" diff --git a/tests/string.out b/tests/string.out index 45ccb369..bd3fff45 100644 --- a/tests/string.out +++ b/tests/string.out @@ -1,3 +1,18 @@ +dog +diz +exit 0 +exit 0 +dog +diz +exit 0 +exit 0 +exit 1 +exit 1 +y +exit 0 +exit 1 +exit 0 +exit 1 12 ab bc @@ -45,3 +60,5 @@ aabb invalid expression error invalid argument error missing argument returns 0 +no regexp invert match +no glob invert match |