summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-10-22 18:01:48 +0200
committerLubomir Rintel <lkundrak@v3.sk>2018-10-23 15:42:19 +0200
commit05d6c993dd0cee474540f74902d213d084a86782 (patch)
tree3ef8f6af88e810f1d2d590c1dcc1512aa39248e4
parentd49e88f716aea64b20083f4e5fd1fdecda881f22 (diff)
downloadNetworkManager-lr/readline-init.tar.gz
cli: initialize readline before installing the redisplay handlerlr/readline-init
Otherwise readline decides to initialize terminal handling at the first readline call, and if that happens at the point it sees our non-echoing rl_redisplay. At that point, unless already intialized, readline wrongly convinces itself we do our own handling of terminal peculiarities (such as cursor movement, or erases). We do not -- we merely wrap the stock rl_redisplay(), temporarily hiding the actual characters. The rl_initialize() in nmc_readline_echo()s fixes broken line editing in password prompts that weren't preceded a previous non-password prompt. The other one is there for consistency only. (I guess we should be initializing readline before use anyway; although it seems to initialize itself anyway if we fail to do so...) https://github.com/NetworkManager/NetworkManager/pull/241
-rw-r--r--clients/cli/common.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c
index 71b8e9c00d..945cd5b474 100644
--- a/clients/cli/common.c
+++ b/clients/cli/common.c
@@ -941,6 +941,8 @@ nmc_readline (const NmcConfig *nmc_config,
va_list args;
gs_free char *prompt = NULL;
+ rl_initialize ();
+
va_start (args, prompt_fmt);
prompt = g_strdup_vprintf (prompt_fmt, args);
va_end (args);
@@ -994,6 +996,8 @@ nmc_readline_echo (const NmcConfig *nmc_config,
prompt = g_strdup_vprintf (prompt_fmt, args);
va_end (args);
+ rl_initialize ();
+
/* Hide the actual password */
if (!echo_on) {
saved_history = history_get_history_state ();