From 6a48a0a416a64c30c8ab89b9f468b523f46b1bb9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 9 May 2016 13:58:27 +0100 Subject: [PATCH] [Fix] Try to handle multiline history in a more sane way --- src/rspamadm/lua_repl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c index 36de84c23..c7f873df2 100644 --- a/src/rspamadm/lua_repl.c +++ b/src/rspamadm/lua_repl.c @@ -394,6 +394,7 @@ rspamadm_lua_run_repl (lua_State *L) gchar *input; gboolean is_multiline = FALSE; GString *tb; + guint i; for (;;) { if (!is_multiline) { @@ -435,11 +436,20 @@ rspamadm_lua_run_repl (lua_State *L) is_multiline = FALSE; linenoiseFree (input); rspamadm_exec_input (L, tb->str); + + /* Replace \n with ' ' for sanity */ + for (i = 0; i < tb->len; i ++) { + if (tb->str[i] == '\n') { + tb->str[i] = ' '; + } + } + + linenoiseHistoryAdd (tb->str); g_string_free (tb, TRUE); } else { g_string_append (tb, input); - g_string_append (tb, "\n"); + g_string_append (tb, " \n"); linenoiseFree (input); } } -- 2.39.5