diff --git a/tools/vsh.c b/tools/vsh.c index 58855f63ba..e74045c24e 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2973,7 +2973,7 @@ vshReadlineInit(vshControl *ctl) const char *quote_characters = "\"'"; /* initialize readline stuff only once */ - if (ctl->historydir) + if (autoCompleteOpaque) return 0; /* Opaque data for autocomplete callbacks. */ @@ -2989,6 +2989,11 @@ vshReadlineInit(vshControl *ctl) rl_completer_quote_characters = quote_characters; rl_char_is_quoted_p = vshReadlineCharIsQuoted; + /* Stuff below is needed only for interactive mode. */ + if (!ctl->imode) { + return 0; + } + histsize_env = g_strdup_printf("%s_HISTSIZE", ctl->env_prefix); /* Limit the total size of the history buffer */ @@ -3149,7 +3154,7 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups) cmdGroups = groups; if (vshInitDebug(ctl) < 0 || - (ctl->imode && vshReadlineInit(ctl) < 0)) + vshReadlineInit(ctl) < 0) return false; return true; @@ -3168,7 +3173,7 @@ vshInitReload(vshControl *ctl) if (ctl->imode) vshReadlineDeinit(ctl); - if (ctl->imode && vshReadlineInit(ctl) < 0) + if (vshReadlineInit(ctl) < 0) return false; return true;