From 6cd6b3b74ea227e9f1473422ba86b37d95bac68f Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Sun, 18 Jun 2023 10:37:05 +1100 Subject: [PATCH] fix help call of state command --- src/include/66/ssexec.h | 2 ++ src/lib66/exec/ssexec_state.c | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/include/66/ssexec.h b/src/include/66/ssexec.h index cea8af40..bac0f569 100644 --- a/src/include/66/ssexec.h +++ b/src/include/66/ssexec.h @@ -245,6 +245,8 @@ extern char const *help_halt ; #define OPTS_SIGNAL_LEN (sizeof OPTS_SIGNAL - 1) #define OPTS_ENV "hc:s:VLr:e:i:" #define OPTS_ENV_LEN (sizeof OPTS_ENV - 1) +#define OPTS_STATE "h" +#define OPTS_STATE_LEN (sizeof OPTS_STATE - 1) #define OPTS_TREE_WRAPPER "h" #define OPTS_TREE_WRAPPER_LEN (sizeof OPTS_TREE_WRAPPER - 1) diff --git a/src/lib66/exec/ssexec_state.c b/src/lib66/exec/ssexec_state.c index cb28b866..539f9ea3 100644 --- a/src/lib66/exec/ssexec_state.c +++ b/src/lib66/exec/ssexec_state.c @@ -19,6 +19,7 @@ #include <skalibs/types.h> #include <skalibs/lolstdio.h> #include <skalibs/buffer.h> +#include <skalibs/sgetopt.h> #include <66/info.h> #include <66/resolve.h> @@ -81,8 +82,27 @@ int ssexec_state(int argc, char const *const *argv, ssexec_t *info) "issupervised", "isup" } ; - argc-- ; - argv++ ; + { + subgetopt l = SUBGETOPT_ZERO ; + + for (;;) + { + int opt = subgetopt_r(argc, argv, OPTS_ENABLE, &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