From 6deeb46561c122f22bb289522520bc458636a796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 13 Jan 2023 22:54:52 +0100 Subject: GDB: replay last command on empty input --- src/GDB.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/GDB.hs') diff --git a/src/GDB.hs b/src/GDB.hs index f738bec..f360637 100644 --- a/src/GDB.hs +++ b/src/GDB.hs @@ -177,13 +177,14 @@ gdbCommand gdb cmd = do gdbSession :: MonadOutput m => GDB -> m () gdbSession gdb = do outPrompt "gdb> " - loop + loop "" outClearPrompt where - loop = liftIO (catchIOError (Just <$> T.getLine) (\e -> if isEOFError e then return Nothing else ioError e)) >>= \case + loop prev = liftIO (catchIOError (Just <$> T.getLine) (\e -> if isEOFError e then return Nothing else ioError e)) >>= \case Just line -> do - gdbCommand gdb ("-interpreter-exec console \"" <> line <> "\"") - loop + let cmd = if T.null line then prev else line + gdbCommand gdb ("-interpreter-exec console \"" <> cmd <> "\"") + loop cmd Nothing -> return () -- cgit v1.2.3