bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch #6111] Shell script that produces a pipeline of greps


From: Stepan Kasal
Subject: [patch #6111] Shell script that produces a pipeline of greps
Date: Mon, 23 Jul 2007 13:39:37 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070530 Fedora/1.5.0.12-1.fc6 Firefox/1.5.0.12

Update of patch #6111 (project grep):

                  Status:                    None => Wont Do                
             Assigned to:                    None => kasal                  
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #1:

Hi,
  with the description:

> comma stands for logical or, minus for logical not, and everything else is
and'ed

I would interpret "image,picture -gtk,gnome" as
   image OR (picture AND NOT gtk) OR gnome
because unary operator usually has the highest priority, and AND usually has
higher priority than OR.
And I would expect the script would interpret parentheses as well.

But I think it is more natural to use awk for such a task, instead of several
processes.  For example, the above example can be implemented with GNU awk
this way:

$ apt-cache search view |
  gawk 'BEGIN{IGNORECASE=1};
        (/image/ || /picture/) && !(/gtk/ || /gnome/)'

As you see, you can use the full power of logical expressions.

Or, if portability to any POSIX-conformant awk implementation were needed:

$ apt-cache search view |
  gawk '{l=tolower($0)};
        (l~/image/ || l~/picture/) && !(l~/gtk/ || l~/gnome/)'

To conclude, I do not think your script is suitable for inclusion to the GNU
grep distribution.

In any case, thank you for your suggestion!

Have a nice day,
    Stepan Kasal

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?6111>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]