From dd76e8265343e70bbdb35aeceb6aaab35ae4e2d9 Mon Sep 17 00:00:00 2001 From: darkcoven Date: Sat, 12 Oct 2013 18:32:48 +0200 Subject: [PATCH] Cli: switch to filename completion after terminal commands --- cli/src/admin.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cli/src/admin.c b/cli/src/admin.c index 73ea79c..ffc567f 100644 --- a/cli/src/admin.c +++ b/cli/src/admin.c @@ -86,7 +86,6 @@ static char* my_generator (const char* text, int state) static char** my_completion (const char *text, int start, int end UNUSED) { - char **matches = NULL; char *line, *com[MAXCOM]; int i, n; @@ -99,16 +98,15 @@ static char** my_completion (const char *text, int start, int end UNUSED) free(line); compcur = getSubCom(com, n, &i); - - if (i < n) - compcur = NULL; - matches = rl_completion_matches(text, my_generator); - for (i = 0; com[i] != NULL; i++) free(com[i]); - - return matches; + if (i < n) /* unknown command */ + return NULL; + else if (compcur->sub == NULL) /* terminal command */ + return rl_completion_matches(text, rl_filename_completion_function); + else /* intermediate command */ + return rl_completion_matches(text, my_generator); } #endif /* HAVE_LIBREADLINE */ -- 2.39.5