On 5/2/20 1:55 PM, John H Palmieri wrote:
> 
> OMG, why does "sage -grep" use the "find" command?
> 

Others have pointed out that "-r" isn't standard, but "-r" is wrong
anyway. It's only supposed to search through python files. And having
"find" look for those files isn't any slower than having grep do it --
that's why "-r" isn't a standard flag, it's redundant.

But your OMG is justified for another reason,

 find sage -print | GREP_OPTIONS= egrep '.py([xdi])?$' | xargs grep "$@"

is calling egrep on the output to find the files with pythonic
extensions, when "find -name" exists to do just that. Also, a pointless
use of xargs. Here's what it should be:

  find ./ \( -name '*.py' \
             -o -name '*.pyx' \
             -o -name '*.pyd' \
             -o -name '*.pyi' \) \
          -exec grep "$@" {} +

That's all POSIX and can be run with /bin/sh and not /bin/bash.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/ab8fb8de-d822-be3b-6e1a-684381d767b9%40orlitzky.com.

Reply via email to