aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}