3 ms·
Why doesn't POSIX include the "-o" option. The word "often" in the parent comment implies there are times when GNU grep is not better suited than sed with ERE.
by 1vuio0pswjnm7 4y ago
Why doesn't POSIX include the "-o" option.
The word "often" in the parent comment implies there are times when GNU grep is not better suited than sed with ERE. (I often use flex instead of sed.)
For example,
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44754 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44754
Or from the 3.8 manual:
6.1 Known Bugs
Large repetition counts in the `{n,m}' construct may cause grep to use lots of memory. In addition, certain other obscure regular expressions require exponential time and space, and may cause grep to run out of memory.
Back-references can greatly slow down matching, as they can generate exponentially many matching possibilities that can consume both time and memory to explore. Also, the POSIX specification for back-references is at times unclear. Furthermore, many regular expression implementations have back-reference bugs that can cause programs to return incorrect answers or even crash, and fixing these bugs has often been low-priority: for example, as of 2021 the GNU C library bug database contained back-reference bugs 52, 10844, 11053, 24269 and 25322, with little sign of forthcoming fixes. Luckily, back-references are rarely useful and it should be little trouble to avoid them in practical applications.
- asicsp 4y ago>there are times when GNU grep is not better suited than sed with ERE Because, among other things, sed has filtering features like based on line numbers, address range, etc that aren't present in grep. Regarding known bugs, that probably extends to GNU sed/awk as well. An issue I filed (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26864 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26864) led to the manual update about back-reference bugs.
- deleted 4y ago[deleted]