summaryrefslogtreecommitdiff
path: root/src/GF/Shell.hs
diff options
context:
space:
mode:
authoraarne <unknown>2005-10-05 19:02:19 +0000
committeraarne <unknown>2005-10-05 19:02:19 +0000
commita78acc722ec26be2be20f22f74e98329d57008b1 (patch)
tree218294b2a57d3b6f8edce7730b9aa97d7537fadf /src/GF/Shell.hs
parent1703bb826e314eb78c15f846af1e76784f7759e2 (diff)
grep etc
Diffstat (limited to 'src/GF/Shell.hs')
-rw-r--r--src/GF/Shell.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs
index 8ae01017c..6e3b241c0 100644
--- a/src/GF/Shell.hs
+++ b/src/GF/Shell.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/07/01 08:16:32 $
+-- > CVS $Date: 2005/10/05 20:02:19 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.42 $
+-- > CVS $Revision: 1.43 $
--
-- GF shell command interpreter.
-----------------------------------------------------------------------------
@@ -51,7 +51,7 @@ import GF.Grammar.PrGrammar
import Control.Monad (foldM,liftM)
import System (system)
import System.Random (newStdGen) ----
-import Data.List (nub)
+import Data.List (nub,isPrefixOf)
import GF.Data.Zipper ----
import GF.Data.Operations
@@ -269,6 +269,8 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of
CSystemCommand s -> justOutput opts (system s >> return ()) sa
CPutString -> changeArg (opSS2CommandArg (optStringCommand opts gro)) sa
----- CShowTerm -> changeArg (opTS2CommandArg (optPrintTerm opts gro) . s2t) sa
+ CGrep ms -> changeArg (AString . unlines . filter (grep ms) . lines . prCommandArg) sa
+
CSetFlag -> changeState (addGlobalOptions opts0) sa
---- deprec! CSetLocalFlag lang -> changeState (addLocalOptions lang opts0) sa
@@ -327,6 +329,11 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of
then (putStrLn ("Warning: discontinuous category" +++ prt_ c))
else (return ())
+ grep ms s = (if oElem beVerbose opts then not else id) $ grepv ms s --- -v
+ grepv ms s = case s of
+ _:cs -> isPrefixOf ms s || grepv ms cs
+ _ -> isPrefixOf ms s
+
-- commands either change the state or process the argument, but not both
-- some commands just do output