What grep command will include the current function name in its output?

前端 未结 9 2069
夕颜
夕颜 2021-01-07 18:08

I run diff with the -p option so the output will include the name of the function where each change occurred. Is there an analogous option for

9条回答
  •  广开言路
    2021-01-07 18:24

    Unfortunately, no. This feature does not exist in grep nor does it exist in ack (which is ab improved grep replacement).

    I really do wish this existed, though. It would come in handy. Someone did take a shot at implementing it a while back, but it doesn't look like their patch ever got accepted (or was ever even posted online, strangely). You can try emailing him and see if he still has the code and still wants to get an option to show C functions into grep.

    You could write a regular expression to match a C function, but I bet that'd be one monster of a regexp.

提交回复
热议问题