[Omake] grep -v

David Kågedal david at virtutech.se
Tue Sep 19 05:26:29 PDT 2006


I noticed that Shell.grep (which is $(builtin-grep)) doesn't handle
the -v flag, even though the grep function has a corresponding "v"
flag.  And similar with the -h flag.

Also, it seems that $(grep H, ...) is treated like $(grep h, ...),
although "grep -h" and "grep -H" are typically the inverse of
each other.

This patch seems to take care of, but a couple of tests should
probably be written as well.

--- omake_builtin_io_fun.ml	(revision 9564)
+++ omake_builtin_io_fun.ml	(working copy)
@@ -237,13 +237,13 @@
       else
          let flag =
             match s.[i] with
-               'q' | 'Q' ->
+               'q' ->
                   GrepQuiet
-             | 'n' | 'N' ->
+             | 'n' ->
                   GrepPrint
-             | 'v' | 'V' ->
+             | 'v' ->
                   GrepNoMatch
-             | 'h' | 'H' ->
+             | 'h' ->
                   GrepNoPrint
              | c ->
                   raise (OmakeException (loc_pos loc pos, StringStringError ("illegal grep option", String.make 1 c)))
@@ -354,6 +354,10 @@
                       collect ("q" ^ flags) args
                  | "-n" ->
                       collect ("n" ^ flags) args
+                 | "-v" ->
+                      collect ("v" ^ flags) args
+                 | "-h" ->
+                      collect ("h" ^ flags) args
                  | pattern ->
                       flags, pattern, args)
           | [] ->


-- 
David Kågedal, Virtutech



More information about the Omake mailing list