summaryrefslogtreecommitdiff
path: root/vtysh
diff options
context:
space:
mode:
authorChristian Franke <chris@opensourcerouting.org>2013-03-04 09:23:30 +0000
committerDavid Lamparter <equinox@opensourcerouting.org>2013-07-31 17:58:05 +0200
commit67e7a2127c05a8c7dfddd7ffc6378edf6b666d55 (patch)
treec2fa4ed97da789f0948736bd34281c0d6b252ee4 /vtysh
parent8ff202e2d3fa7ebbd6728fdd230f3ad1a20578cd (diff)
vtysh: don't append superflous spaces (BZ#750)
rl_completion_append_character is reset to space every time the completion function is entered. So we would have to set it to '\0' every time new_completion() is called. We can make this conditional and avoid using rl_pending_input. This code path is most relevant when there are multiple completion matches with the same prefix, e.g. in router bgp context: "neighbor 1.2.3.4 pa"<ssive|ssword> would have been completed to "neighbor 1.2.3.4 pass " instead of "neighbor 1.2.3.4 pass". Signed-off-by: Christian Franke <chris@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index e3709e07..c575902c 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -677,8 +677,9 @@ new_completion (char *text, int start, int end)
if (matches)
{
rl_point = rl_end;
- if (complete_status == CMD_COMPLETE_FULL_MATCH)
- rl_pending_input = ' ';
+ if (complete_status != CMD_COMPLETE_FULL_MATCH)
+ /* only append a space on full match */
+ rl_completion_append_character = '\0';
}
return matches;
@@ -2214,9 +2215,6 @@ vtysh_readline_init (void)
rl_bind_key ('?', (Function *) vtysh_rl_describe);
rl_completion_entry_function = vtysh_completion_entry_function;
rl_attempted_completion_function = (CPPFunction *)new_completion;
- /* do not append space after completion. It will be appended
- * in new_completion() function explicitly. */
- rl_completion_append_character = '\0';
}
char *