aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2023-01-04 05:21:10 +0000
committerKyle Evans <kevans@FreeBSD.org>2023-01-04 05:37:54 +0000
commite898a3af97f97f74c0fb22032bbd163f7cc92a05 (patch)
tree90d18981789b5458f8bda5b73581505974537da1 /usr.bin/grep
parenteb03c1f81cbce1d248ebf872bcb035cc6fd7c5de (diff)
Diffstat (limited to 'usr.bin/grep')
-rw-r--r--usr.bin/grep/grep.c1
-rwxr-xr-xusr.bin/grep/tests/grep_freebsd_test.sh13
2 files changed, 14 insertions, 0 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index 6306cbff5932..3f16d118f0d8 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -562,6 +562,7 @@ main(int argc, char *argv[])
break;
case 'z':
fileeol = '\0';
+ cflags &= ~REG_NEWLINE;
break;
case BIN_OPT:
if (strcasecmp("binary", optarg) == 0)
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
}