From 16065cc731687eb8779d31b79436bbf79c5e3ed3 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Tue, 20 Oct 2015 12:22:23 +0200 Subject: sss_tools: always show common and help options popt don't handle merging NULL option table, thus common and help options were not displayed when command doesn't have any options. Reviewed-by: Pavel Reichl --- src/tools/common/sss_tools.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index c0b525555..abb9dbace 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -262,6 +262,19 @@ int sss_tool_route(int argc, const char **argv, return sss_tool_usage(argv[0], commands); } +static struct poptOption *nonnull_popt_table(struct poptOption *options) +{ + static struct poptOption empty[] = { + POPT_TABLEEND + }; + + if (options == NULL) { + return empty; + } + + return options; +} + int sss_tool_popt_ex(struct sss_cmdline *cmdline, struct poptOption *options, enum sss_tool_opt require_option, @@ -272,7 +285,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline, const char **_fopt) { struct poptOption opts_table[] = { - {NULL, '\0', POPT_ARG_INCLUDE_TABLE, options, \ + {NULL, '\0', POPT_ARG_INCLUDE_TABLE, nonnull_popt_table(options), \ 0, _("Command options:"), NULL }, {NULL, '\0', POPT_ARG_INCLUDE_TABLE, sss_tool_common_opts_table(), \ 0, _("Common options:"), NULL }, -- cgit