GNU bug report logs - #75197
[Feature Request] Support 'grep -A' without number to show all lines after match

Previous Next

Package: grep;

Reported by: KMRH <kmrh47 <at> proton.me>

Date: Mon, 30 Dec 2024 12:09:02 UTC

Severity: wishlist

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: KMRH <kmrh47 <at> proton.me>
To: "bug-grep <at> gnu.org" <bug-grep <at> gnu.org>
Subject: [Feature Request] Support 'grep -A' without number to show all lines
 after match
Date: Mon, 30 Dec 2024 11:37:27 +0000
[Message part 1 (text/plain, inline)]
Package: grep
Severity: wishlist

Dear Maintainers,

I would like to request a feature enhancement for the grep tool.

Feature Request
Allow the command 'grep -A' (without specifying a number) to default to showing all lines after a match, instead of erroring out. This would be conceptually equivalent to something like using a very large number ('grep -A 999999 <pattern>'), but without having to manually pick a placeholder length.

Current Behavior
$ grep -A <pattern>
grep: <pattern>: Invalid context length argument

Proposed Behavior
$ grep -A <pattern> # show all lines after match

Rationale

- Intuitive defaults: If no numeric limit is specified, show everything after the match.

- Cleaner syntax: Avoids the arbitrary use of large numbers.
- Unix philosophy: Simple, predictable defaults that reduce friction.
- Alternative approach: If there’s concern about backward compatibility, consider a more explicit flag like '-A all'

I acknowledge that some scripts may rely on the current error behavior for an empty '-A' argument. However, I believe that in most cases it would not cause significant breakage. If necessary, we could introduce a distinct option to avoid disrupting existing usage.

Thank you for considering this enhancement.

Best regards,
Karsten Holmøe
[Message part 2 (text/html, inline)]

This bug report was last modified 167 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.