A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1941 ====================================================================== Reported By: dwheeler Assigned To: ajosey ====================================================================== Project: 1003.1(2008)/Issue 7 Issue ID: 1941 Category: Shell and Utilities Type: Enhancement Request Severity: Objection Priority: normal Status: Under Review Name: David A. Wheeler Organization: User Reference: Section: grep Page Number: 1 Line Number: 1 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2025-08-30 21:51 UTC Last Modified: 2025-09-01 17:10 UTC ====================================================================== Summary: Add widely-implemented options to grep ======================================================================
---------------------------------------------------------------------- (0007250) dwheeler (reporter) - 2025-09-01 17:10 https://austingroupbugs.net/view.php?id=1941#c7250 ---------------------------------------------------------------------- I asked Claude Code to analyze the support of OpenBSD and NetBSD for these proposed new grep options. I had previously looked at FreeBSD. That way at least FreeBSD, OpenBSD, and NetBSD are considered. I tweaked what it reported; here's the tweaked version: | Option | OpenBSD | NetBSD | Notes | |--------|----------|----------|----------------------| | -A NUM | supports | supports | Identical| | -B NUM | supports | supports | Identical | | -G | supports | supports | Default behavior | | -H | supports | supports | Identical | | -L | supports | supports | Identical | | -h | supports | supports | Identical | | -m NUM | variance | variance | Slight variation on context | | -o | supports | supports | Identical | There's extraordinary agreement in general on these grep options. I think everyone uses group separator '--' for -A and -B by default (where they are supported), which is happy news. The main variance appears to be with the -m option: If -m stops output, OpenBSD's implementation doesn't output trailing context, while NetBSD's does. I think OpenBSD's is the better semantic, because maybe we *don't* want to keep reading after that for some particular reason. That also seems to be what everyone else does (MacOS, GNU). However, I'm fine with making that a permitted variance if that's necessary for standardization. So if that variance must be permitted, modify -m to say: > -m NUM Immediately stop reading a file after NUM selections. It is permitted (but not recommended) to read and print context lines afterwards if context lines afterwards were requested. Issue History Date Modified Username Field Change ====================================================================== 2025-08-30 21:51 dwheeler New Issue 2025-08-30 21:51 dwheeler Status New => Under Review 2025-08-30 21:51 dwheeler Assigned To => ajosey 2025-08-30 21:56 dwheeler Note Added: 0007240 2025-08-30 21:59 dwheeler Note Added: 0007241 2025-08-31 00:07 mirabilos Note Added: 0007242 2025-08-31 00:10 mirabilos Note Added: 0007243 2025-08-31 21:52 dwheeler Note Added: 0007244 2025-08-31 22:01 dwheeler Note Added: 0007245 2025-09-01 05:57 stephane Note Added: 0007246 2025-09-01 06:05 stephane Note Added: 0007247 2025-09-01 15:36 dwheeler Note Added: 0007249 2025-09-01 17:10 dwheeler Note Added: 0007250 ======================================================================
