summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-07 07:47:58 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-07 07:47:58 +0200
commit715def65554892b0f75861391823ed0295492e71 (patch)
tree6b62f8673b1ba339e5047a37615f850398260de7
parente3f1bcecae5e4ab08e5cd7c58ee163fab6635ea4 (diff)
downloadxK-715def65554892b0f75861391823ed0295492e71.tar.gz
xK-715def65554892b0f75861391823ed0295492e71.tar.xz
xK-715def65554892b0f75861391823ed0295492e71.zip
degesch: fix option completion
-rw-r--r--degesch.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/degesch.c b/degesch.c
index 8b4a30b..e00a224 100644
--- a/degesch.c
+++ b/degesch.c
@@ -5212,12 +5212,21 @@ complete_option (struct app_context *ctx, struct completion *data,
struct str_vector options;
str_vector_init (&options);
- // Wildcard expansion is an interesting side-effect
- char *x = xstrdup_printf ("%s*", word);
- dump_matching_options (ctx, x, &options);
- free (x);
+ config_dump (ctx->config.root, &options);
+ str_vector_sort (&options);
- str_vector_add_vector (output, options.vector);
+ // Wildcard expansion is an interesting side-effect
+ char *mask = xstrdup_printf ("%s*", word);
+ for (size_t i = 0; i < options.len; i++)
+ {
+ const char *line = options.vector[i];
+ char *key = xstrndup (line, strcspn (line, " "));
+ if (!fnmatch (mask, key, 0))
+ str_vector_add_owned (output, key);
+ else
+ free (key);
+ }
+ free (mask);
str_vector_free (&options);
}