Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Remove -p option in grep builtin and review other options #1283

Open
@dannyweldon

Description

@dannyweldon

If the grep builtin is re-instated as part of #1282, I think the -p option should be removed or changed to something else as it is currently being used as such:

  -p, --strict|pedantic
                  Enable strict pattern interpretation with diagnostics.

Previously, I believe it was aliased to -P. However, -p is used in AIX [1] and Tru64 [2] for paragraph grepping, which, if you have ever had the need and used it, is extremely convenient. And example of this usage would be if you had an error log file with blocks of related lines all together, such as a stack trace, but each block is separated by a blank line. Some java log files are like this. This option then allows you to simply do this:

grep -p ERROR myapp.log | less

which then prints every whole paragraph that contains the string "ERROR", separated by a blank line.

It would be better to reserve -p for a possible future paragraph grep enhancement should someone feel inspired to write it. This would have the added benefit of being the only grep utility available on Linux with this capability as the GNU maintainers have so far not implemented it [3], but they may do at some point. As a replacement for -p, I would have suggested -S, however this has already been used (see below), so perhaps it could just be reduced to being only the long options.

It would be a good idea to review all the options in grep before re-instating it and users become dependant on it. Here are my thoughts for the other options so far:

-T --test this is used in GNU grep as --initial-tab, so this probably should be changed as well.

While these next options make sense, there is a possibility that they could get used in GNU grep for something completely different, but maybe that's acceptable:

-K --ksh-regexp
-X --augmented-regexp
-S --sh-regexp
-N --name

-r|-R seems to be broken as it depends on the tw command being available.

[1] https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.cmds2/grep.htm

[2] http://nixdoc.net/man-pages/Tru64/man1/grep.1.html

[3] http://savannah.gnu.org/bugs/?14630

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions