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

Reply via email to