aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/grep/tests/grep_freebsd_test.sh
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2023-01-04 05:21:10 +0000
committerKyle Evans <kevans@FreeBSD.org>2023-01-28 15:45:05 +0000
commita1362d625340c96c3e95f470efec64c00cea3f6f (patch)
treeb197cb579a19e79228fc9e519f234629fdc1b3f5 /usr.bin/grep/tests/grep_freebsd_test.sh
parent2cfb60783900b625798c5ceb52b9aa93c5c412ae (diff)
grep: properly switch EOL indicator with -z
-z is supposed to use only the NUL byte as EOL, but we were inadvertently using both newline and NUL due to REG_NEWLINE in cflags. The odds of anyone relying on this bsdgrep-specific bug are quite low, so let's just fix it. At least one port in the wild has been reported to expect the intended behavior. Reported by: Hill Ma <maahiuzeon@gmail.com> Triaged by: the self-proclaimed peanut gallery on Discord (cherry picked from commit e898a3af97f97f74c0fb22032bbd163f7cc92a05)
Diffstat (limited to 'usr.bin/grep/tests/grep_freebsd_test.sh')
-rwxr-xr-xusr.bin/grep/tests/grep_freebsd_test.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/usr.bin/grep/tests/grep_freebsd_test.sh b/usr.bin/grep/tests/grep_freebsd_test.sh
index 0d068d5d1c65..f6881791357c 100755
--- a/usr.bin/grep/tests/grep_freebsd_test.sh
+++ b/usr.bin/grep/tests/grep_freebsd_test.sh
@@ -92,9 +92,22 @@ gnuext_body()
}
+atf_test_case zflag
+zflag_body()
+{
+
+ # The -z flag should pick up 'foo' and 'bar' as on the same line with
+ # 'some kind of junk' in between; a bug was present that instead made
+ # it process this incorrectly.
+ printf "foo\nbar\0" > in
+
+ atf_check grep -qz "foo.*bar" in
+}
+
atf_init_test_cases()
{
atf_add_test_case grep_r_implied
atf_add_test_case rgrep
atf_add_test_case gnuext
+ atf_add_test_case zflag
}