Date: Tue, 09 Jun 2020 21:53:08 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 247126] [PATCH] zgrep(1) does not handle -f FILE correctly Message-ID: <bug-247126-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D247126 Bug ID: 247126 Summary: [PATCH] zgrep(1) does not handle -f FILE correctly Product: Base System Version: 12.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: leres@freebsd.org Somewhere between FreeBSD 11 and 12, zfgrep and friends became a wrapper sh= ell script. We've found that it does not handle the -f flag correctly: # Works % zfgrep RELEASE /etc/motd FreeBSD 12.1-RELEASE-p3 GENERIC=20 # Hangs reading from stdin % echo RELEASE > /tmp/0 % zfgrep -f /tmp/0 /etc/motd /etc/motd:FreeBSD 12.1-RELEASE-p3 GENERIC ^Z Suspended leviathan 89 % ps t PID TT STAT TIME COMMAND 11249 4 Ss 0:00.11 -csh (csh) 12190 4 T 0:00.00 /bin/sh /usr/bin/zfgrep -f /tmp/0 /etc/motd 12191 4 T 0:00.00 /usr/bin/zcat -f - 12192 4 T 0:00.00 grep -F -f /tmp/0 -- /etc/motd - 12193 4 R+ 0:00.00 ps t The problem is when -f is used there is no command line pattern and the wra= pper script incorrectly uses the first non-flag argument as a pattern and incorrectly decides we want to read from stdin. Meanwhile grep is invoked w= ith the pattern (really the target file) and a '-'. In then outputs any matches= and hangs, reading from stdin. Here's the most minimal patch I could develop in two minutes. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-247126-227>