From d1093d670f0ba2eb7f0f9d1222e4a6b941a350e4 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 13 Oct 2022 19:26:10 -0500 Subject: [PATCH] Test that -z doesn't apply to the \n in input patterns. --- tests/grep.test | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/grep.test b/tests/grep.test index f7efabab..893655f6 100755 --- a/tests/grep.test +++ b/tests/grep.test @@ -193,7 +193,12 @@ testcmd "-Fix" "-Fix h input" "H\nh\n" \ "missing\nH\nthis is HELLO\nthis is WORLD\nh\nmissing" "" testcmd "-F bucket sort" "-F '\.zip'" '\\.zip\n' '' '\\.zip\n' testcmd "-f /dev/null" "-f /dev/null" "" "" "hello\n" -testcmd "-z with \n in pattern" "-f input" "hi\nthere\n" "i\nt" "hi\nthere" + +# -z doesn't apply to the \n in -e or -f patterns +# Because x\n becomes "x" and "" the second of which matches every line. +testcmd '-z patter\n' "-ze $'x\n' | xxd -pc0" \ + '6f6e650a74776f0a74687265650a00\n' '' 'one\ntwo\nthree\n' +testcmd "-z patter\n 2" "-zof input | xxd -pc0" "69007400\n" "i\nt" "hi\nthere" testcmd "print zero length match" "'[0-9]*'" "abc\n" "" "abc\n" testcmd "-o skip zero length match" "-o '[0-9]*'" "1234\n" "" "a1234b" -- 2.39.2