projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7bcf459
)
don't call Haskeline to read input when stdin is not a terminal
author
Simon Marlow
<marlowsd@gmail.com>
Thu, 28 May 2009 15:26:51 +0000
(15:26 +0000)
committer
Simon Marlow
<marlowsd@gmail.com>
Thu, 28 May 2009 15:26:51 +0000
(15:26 +0000)
ghc/InteractiveUI.hs
patch
|
blob
|
history
diff --git
a/ghc/InteractiveUI.hs
b/ghc/InteractiveUI.hs
index
1fcae52
..
d620290
100644
(file)
--- a/
ghc/InteractiveUI.hs
+++ b/
ghc/InteractiveUI.hs
@@
-420,7
+420,7
@@
runGHCi paths maybe_exprs = do
Nothing ->
do
-- enter the interactive loop
Nothing ->
do
-- enter the interactive loop
- runGHCiInput $ runCommands $ haskelineLoop show_prompt
+ runGHCiInput $ runCommands $ nextInputLine show_prompt is_tty
Just exprs -> do
-- just evaluate the expression we were given
enqueueCommands exprs
Just exprs -> do
-- just evaluate the expression we were given
enqueueCommands exprs
@@
-448,13
+448,14
@@
runGHCiInput f = do
setLogAction
f
setLogAction
f
--- TODO really bad name
-haskelineLoop :: Bool -> InputT GHCi (Maybe String)
-haskelineLoop show_prompt = do
+nextInputLine :: Bool -> Bool -> InputT GHCi (Maybe String)
+nextInputLine show_prompt is_tty
+ | is_tty = do
prompt <- if show_prompt then lift mkPrompt else return ""
prompt <- if show_prompt then lift mkPrompt else return ""
- l <- getInputLine prompt
- return l
-
+ getInputLine prompt
+ | otherwise = do
+ when show_prompt $ lift mkPrompt >>= liftIO . putStr
+ fileLoop stdin
-- NOTE: We only read .ghci files if they are owned by the current user,
-- and aren't world writable. Otherwise, we could be accidentally
-- NOTE: We only read .ghci files if they are owned by the current user,
-- and aren't world writable. Otherwise, we could be accidentally
@@
-490,7
+491,7
@@
checkPerms name =
fileLoop :: MonadIO m => Handle -> InputT m (Maybe String)
fileLoop hdl = do
fileLoop :: MonadIO m => Handle -> InputT m (Maybe String)
fileLoop hdl = do
- l <- liftIO $ IO.try (BS.hGetLine hdl)
+ l <- liftIO $ IO.try $ hGetLine hdl
case l of
Left e | isEOFError e -> return Nothing
| InvalidArgument <- etype -> return Nothing
case l of
Left e | isEOFError e -> return Nothing
| InvalidArgument <- etype -> return Nothing
@@
-500,7
+501,7
@@
fileLoop hdl = do
-- this can happen if the user closed stdin, or
-- perhaps did getContents which closes stdin at
-- EOF.
-- this can happen if the user closed stdin, or
-- perhaps did getContents which closes stdin at
-- EOF.
- Right l -> fmap Just (Encoding.decode l)
+ Right l -> fmap Just (Encoding.decode (BS.pack l))
mkPrompt :: GHCi String
mkPrompt = do
mkPrompt :: GHCi String
mkPrompt = do