Remove -p option in grep builtin and review other options #1283
Description
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