From 59ca127517fa7762f8e5b1930792e488a33e0ef1 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Sat, 11 Mar 2023 19:21:40 +1100 Subject: [PATCH] fix options arguments --- src/lib66/exec/ssexec_init.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/lib66/exec/ssexec_init.c b/src/lib66/exec/ssexec_init.c index 28159faa..adf22c4c 100644 --- a/src/lib66/exec/ssexec_init.c +++ b/src/lib66/exec/ssexec_init.c @@ -22,6 +22,7 @@ #include <oblibs/graph.h> #include <skalibs/stralloc.h> +#include <skalibs/sgetopt.h> #include <66/constants.h> #include <66/config.h> @@ -145,6 +146,28 @@ int ssexec_init(int argc, char const *const *argv, ssexec_t *info) stralloc sa = STRALLOC_ZERO ; + { + subgetopt l = SUBGETOPT_ZERO ; + + for (;;) + { + int opt = subgetopt_r(argc, argv, OPTS_INIT, &l) ; + if (opt == -1) break ; + + switch (opt) { + + case 'h' : + + info_help(info->help, info->usage) ; + return 0 ; + + default : + log_usage(info->usage, "\n", info->help) ; + } + } + argc -= l.ind ; argv += l.ind ; + } + if (!argc) log_usage(info->usage, "\n", info->help) ; -- GitLab