summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Interactive2.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/GF/Interactive2.hs')
-rw-r--r--src/compiler/GF/Interactive2.hs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/compiler/GF/Interactive2.hs b/src/compiler/GF/Interactive2.hs
index 70f7e567e..bfa7fd6b2 100644
--- a/src/compiler/GF/Interactive2.hs
+++ b/src/compiler/GF/Interactive2.hs
@@ -11,7 +11,7 @@ import GF.Command.Help(helpCommand)
import GF.Command.Abstract
import GF.Command.Parse(readCommandLine,pCommand)
import GF.Data.Operations (Err(..),done)
-import GF.Data.Utilities(repeatM)
+import GF.Data.Utilities(whenM,repeatM)
import GF.Infra.UseIO(ioErrorText,putStrLnE)
import GF.Infra.SIO
@@ -117,14 +117,18 @@ type ShellM = StateT GFEnv SIO
execute1 :: String -> ShellM Bool
execute1 s0 =
do modify $ \ gfenv0 -> gfenv0 {history = s0 : history gfenv0}
- opts <- gets startOpts
+ execute1' s0
+
+-- | Execute a given command line, without adding it to the history
+execute1' s0 =
+ do opts <- gets startOpts
interruptible $ optionallyShowCPUTime opts $
case pwords s0 of
-- cc, sd, so, ss and dg are now in GF.Commands.SourceCommands
-- special commands
"q" :_ -> quit
"!" :ws -> system_command ws
- "eh":ws -> eh ws
+ "eh":ws -> execute_history ws
"i" :ws -> do import_ ws; continue
-- other special commands, working on GFEnv
"dc":ws -> define_command ws
@@ -158,12 +162,16 @@ execute1 s0 =
cs <- readFile w >>= return . map words . lines
gfenv' <- foldM (flip (process False benv)) gfenv cs
loopNewCPU gfenv' -}
- eh [w] = -- Ehhh? Reads commands from a file, but does not execute them
- do env <- gets commandenv
- cs <- lift $ restricted (readFile w) >>= return . map (interpretCommandLine env) . lines
+ execute_history [w] =
+ do execute . lines =<< lift (restricted (readFile w))
continue
- eh _ = do putStrLnE "eh command not parsed"
- continue
+ where
+ execute [] = done
+ execute (line:lines) = whenM (execute1' line) (execute lines)
+
+ execute_history _ =
+ do putStrLnE "eh command not parsed"
+ continue
define_command (f:ws) =
case readCommandLine (unwords ws) of