@@ -437,10 +437,10 @@ handleKindOf typ = do
437437-- Parses the input and returns either a Metacommand, or an error as a string.
438438--
439439getCommand :: Bool -> InputT (StateT PSCiState IO) (Either String (Maybe Command))
440−getCommand singleLineMode = do
441− firstLine <- getInputLine "> "
440+getCommand singleLineMode = handleInterrupt (return (Right Nothing)) $ do
441+ firstLine <- withInterrupt $ getInputLine "> "
442442 case firstLine of
443− Nothing -> return (Right Nothing)
443+ Nothing -> return (Right (Just QuitPSCi)) -- Ctrl-D when input is empty
444444 Just "" -> return (Right Nothing)
445445 Just s | singleLineMode || head s == ':' -> return . either Left (Right . Just) $ parseCommand s
446446 Just s -> either Left (Right . Just) . parseCommand <$> go [s]
@@ -555,7 +555,10 @@ loop PSCiOptions{..} = do
555555 Left err -> outputStrLn err >> go
556556 Right Nothing -> go
557557 Right (Just QuitPSCi) -> outputStrLn quitMessage
558− Right (Just c') -> runPSCI (loadAllImportedModules >> handleCommand c') >> go
558+ Right (Just c') -> do
559+ handleInterrupt (outputStrLn "Interrupted.")
560+ (withInterrupt (runPSCI (loadAllImportedModules >> handleCommand c')))
561+ go
559562
560563multiLineMode :: Parser Bool
561564multiLineMode = switch $