aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-09 13:58:27 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-09 13:58:27 +0100
commit6a48a0a416a64c30c8ab89b9f468b523f46b1bb9 (patch)
treefabdd1385a4f3c1334df18115e82b6ed646b88e3
parent35647609e6850ec191561f133e2ff5a0aaf4e480 (diff)
downloadrspamd-6a48a0a416a64c30c8ab89b9f468b523f46b1bb9.tar.gz
rspamd-6a48a0a416a64c30c8ab89b9f468b523f46b1bb9.zip
[Fix] Try to handle multiline history in a more sane way
-rw-r--r--src/rspamadm/lua_repl.c12
1 files changed, 11 insertions, 1 deletions
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);
}
}