The branch main has been updated by leres:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=80726c2257e9d6d79341aac65ba22987f53619bc

commit 80726c2257e9d6d79341aac65ba22987f53619bc
Author:     Craig Leres <[email protected]>
AuthorDate: 2025-12-13 23:43:02 +0000
Commit:     Craig Leres <[email protected]>
CommitDate: 2025-12-14 21:15:36 +0000

    Fix zgrep(1) wrapper regression, add test
    
    @bdrewery reported D48873 broke "bzgrep -q '1 2' /var/log/messages.0.bz2"
    The mistake was in using $* instead of "$@" (I suspect $* is never right).
    
    Reported by:    bdrewery
    Reviewed by:    markj
    Approved by:    markj
    Fixes:          1070477cc8b7 ("Fix remaining zgrep(1) wrapper script 
regressions")
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54217
---
 usr.bin/grep/tests/grep_freebsd_test.sh | 10 ++++++++++
 usr.bin/grep/zgrep.sh                   |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/usr.bin/grep/tests/grep_freebsd_test.sh 
b/usr.bin/grep/tests/grep_freebsd_test.sh
index 906b70645151..eaf3694c2b1e 100755
--- a/usr.bin/grep/tests/grep_freebsd_test.sh
+++ b/usr.bin/grep/tests/grep_freebsd_test.sh
@@ -117,6 +117,15 @@ color_dupe_body()
        atf_check -o match:"^ +1 color.out" wc -l color.out
 }
 
+atf_test_case qflag
+qflag_body()
+{
+       # Test whitespace in argument
+       printf "1 2 3 4\n5 6 7 8\n" > in
+
+       atf_check zgrep -q '1 2' in
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case grep_r_implied
@@ -124,4 +133,5 @@ atf_init_test_cases()
        atf_add_test_case gnuext
        atf_add_test_case zflag
        atf_add_test_case color_dupe
+       atf_add_test_case qflag
 }
diff --git a/usr.bin/grep/zgrep.sh b/usr.bin/grep/zgrep.sh
index 8bd630726647..474f3868db9d 100755
--- a/usr.bin/grep/zgrep.sh
+++ b/usr.bin/grep/zgrep.sh
@@ -109,7 +109,7 @@ do
            grep_args="${grep_args} ${pre}"
            shift
            # Put back partial arg
-           set -- "-${post}" $*
+           set -- "-${post}" "$@"
            ;;
        -[ABCDdefm])
            if [ $# -lt 2 ]

Reply via email to