Project

General

Profile

Feature #3546

add support for grep -o option

Added by Andrew Stormont almost 8 years ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

Attached is a patch which adds support for the -o option (only print matched parts) to grep.


Files

illumos-grep-o.patch (1.13 KB) illumos-grep-o.patch Andrew Stormont, 2013-02-10 02:11 PM
#1

Updated by Andrew Stormont about 7 years ago

  • Assignee set to Andrew Stormont
#2

Updated by Yuri Pankov almost 3 years ago

Andrew, I guess you will not be updating your patch for our new shiny grep?

#3

Updated by Robert Mustacchi 4 months ago

  • Category set to cmd - userland programs
  • Assignee changed from Andrew Stormont to Robert Mustacchi
  • Start date deleted (2013-02-10)
  • % Done changed from 0 to 90

I ended up taking a fresh swing at this with the merged grep. To make this easier to implement, and to support it for fgrep and egrep, I went ahead and basically forced us down the path of using the regular expression processing more often instead of having disparate paths for handling multibyte data and other manual pattern methods. This simplifies the code slightly and makes it much easier to implement the -o option, though at the cost of making some cases more expensive. To help ameliorate that I also did #13040, which makes some of this a little more palatable.

#4

Updated by Electric Monk 4 months ago

  • Gerrit CR set to 844
#5

Updated by Robert Mustacchi 3 months ago

I tested this with the updated grep test suite, test run below. This included a number of large additions to the test suite (such as actually testing egrep and fgrep) to better cover other flags that weren't present before. This includes things like -b. While I was able to compare ggrep with a number of items, there are differences in behavior, particularly with options like -b, which means that they aren't always identical; however, the set of matches is always the same.

rm@beowulf:~$ pfexec /opt/util-tests/bin/utiltest 
Test: /opt/util-tests/tests/allowed-ips (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/chown_test (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/date_test (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/find/findtest (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/grep_test (run as root)               [00:03] [PASS]
Test: /opt/util-tests/tests/libjedec_test (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/libsff/libsff (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/make_test (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/mdb/mdbtest (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/mergeq/mqt (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/mergeq/wqt (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/printf_test (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/set-linkprop (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/sleep/sleeptest (run as root)         [00:20] [PASS]
Test: /opt/util-tests/tests/smbios (run as root)                  [00:00] [PASS]
Test: /opt/util-tests/tests/xargs_test (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/awk/runtests.sh (run as nobody)       [02:45] [PASS]
Test: /opt/util-tests/tests/ctf/precheck (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/ctf/ctftest (run as root)             [00:06] [PASS]
Test: /opt/util-tests/tests/demangle/afl-fast (run as root)       [00:01] [PASS]
Test: /opt/util-tests/tests/demangle/gcc-libstdc++ (run as root)  [00:00] [PASS]
Test: /opt/util-tests/tests/demangle/llvm-stdcxxabi (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libcustr/custr_remove (run as root)   [00:00] [PASS]
Test: /opt/util-tests/tests/libcustr/custr_trunc (run as root)    [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_00_blank (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_01_boolean (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_02_numbers (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_03_empty_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_04_number_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_05_strings (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_06_nested (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_07_nested_arrays (run as root) [00:00] [PASS]

Results Summary
PASS      32

Running Time:   00:03:21
Percent passed: 100.0%
Log directory:  /var/tmp/test_results/20200819T140127
#6

Updated by Electric Monk 3 months ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit 81dd18d87c3c2e198d2178dfd1f30d62a81b69ea

commit  81dd18d87c3c2e198d2178dfd1f30d62a81b69ea
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2020-08-25T23:00:10.000Z

    3546 add support for grep -o option
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Toomas Soome <tsoome@me.com>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

Also available in: Atom PDF