From nobody Sat Jan 28 15:45:22 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P3zKt70vHz3b8ys; Sat, 28 Jan 2023 15:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P3zKt6GW9z3yts; Sat, 28 Jan 2023 15:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674920722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O3xZ1VPqHFrl7MkzeT+3aa3QHJV8vqv/Fx8JBC6VQdg=; b=M2PyzxYZzQkLeE3UfAgV67rdLw0ydrzCym77MCJotVJOW326HLy3GGR4VlSUoFoQn0dBaJ 1iQG8HUKSjDchFe4dwfNdY9nFhkSeZ1hGthaUvp3MG2pi3D5DhwVFxblrddUvBFgQblhzc 6ZIg1XPBoaNd63P3KuxL5of5GYTrUBYHAx8vNu1ljvUqroYaXJUq8kH3U0j7m3Yv5vZ6ZT wGT50WpQYPcCUr1tAV7Nttbux/vD4Pw77AoXtBRSKRpht+lmln1rghtW10jEYGJ9wCoY5S m0iLsA7muoP34eevKgZ0pSdtteXwr7KCzdcv9PgENFKc2FGJwBtm1n67jaVzpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674920722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=O3xZ1VPqHFrl7MkzeT+3aa3QHJV8vqv/Fx8JBC6VQdg=; b=cDYAFb+9WHFLusC8hkp7eBHUFFCjEQR8jcP6KLUlkayrkcDAKgrT85HHASxK/+lX/Gy/sE YG5xiBTRPZ3ByVtPtrZGXdrC0D3ccFyafuJJSOf2txvTt2bZ8bhZy0HL9veyhVL8ssUM6D ZWGjQvofbOLqCSzneHHFeQHV6LQUjJpp8tXjzSkM6RTbKqZp2ft+yP6aIdWjAmHl0N9NxI WCOahXd+X2ywxBSH+EvL79jQ9+QnCxkIAd9uaknHMARPADdNWJeMq1CLR4KLt82xCtwv4Z 1ZjPCj12DcaZt4MKKmTVRSL01j1JO4teqbUljsIsiGOzVumZv0aXTBpzsHhfOg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674920722; a=rsa-sha256; cv=none; b=xgyqPvqaaEdzqomOeiqiXhzOzjS2SNhAviA7wSUJmSaj3UnQEWDi9IdyqPPJnBv8Yp/Qj0 rdgFLl/Cn4oQDe01kDji80oGgRi99c6tBHfFvOlTCF21LoQ4oqe7HB7h9LS8hsImR6Hm8E 7ef3d/0UUMEjfOX8PhszEtevxePOelXyPb77UQXOORmR5N3H+UCvOkQIo7rzSLOZOYs6L9 41+/9wDs2dySpCLMOx0ZbDFhLcK7kUQWikYQnK+z9Jjtid3KAbNUyhaYR6ZeXy6Upd1Bz8 flGG3USklgcCfD4xjIXfhk5aeYXPwV83iY5WSFk05+nKUEiwZUgfPYo3adlppQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P3zKt5D48zvND; Sat, 28 Jan 2023 15:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30SFjM0b065800; Sat, 28 Jan 2023 15:45:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30SFjMwA065799; Sat, 28 Jan 2023 15:45:22 GMT (envelope-from git) Date: Sat, 28 Jan 2023 15:45:22 GMT Message-Id: <202301281545.30SFjMwA065799@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: a1362d625340 - stable/13 - grep: properly switch EOL indicator with -z List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a1362d625340c96c3e95f470efec64c00cea3f6f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=a1362d625340c96c3e95f470efec64c00cea3f6f commit a1362d625340c96c3e95f470efec64c00cea3f6f Author: Kyle Evans AuthorDate: 2023-01-04 05:21:10 +0000 Commit: Kyle Evans CommitDate: 2023-01-28 15:45:05 +0000 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 Triaged by: the self-proclaimed peanut gallery on Discord (cherry picked from commit e898a3af97f97f74c0fb22032bbd163f7cc92a05) --- usr.bin/grep/grep.c | 1 + usr.bin/grep/tests/grep_freebsd_test.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 6fbd6bee8ace..f8c38e70e6b3 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 }