From a927190dc47ea0048a482030dccd2981b6310530 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 13 Feb 2022 20:29:52 +0100 Subject: [PATCH] Improve error message of lls_check_arg_count(). When min_argc == max_argc, the function checks whether exactly this many arguments are given. In the error case, it says exactly N non-option args allowed, M given which reads a bit weird. With the patch applied the message becomes exactly N non-option args required, M given --- lopsub.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lopsub.c b/lopsub.c index a9e401f..cbf6661 100644 --- a/lopsub.c +++ b/lopsub.c @@ -736,10 +736,11 @@ int lls_check_arg_count(const struct lls_parse_result *lpr, xasprintf(errctx, "no non-option args allowed, " "%u given", lpr->num_inputs); else - xasprintf(errctx, "%s %u non-option args allowed, " - "%u given", min_argc < max_argc? - "at most" : "exactly", - max_argc, lpr->num_inputs); + xasprintf(errctx, "%s %u non-option args %s, %u given", + min_argc < max_argc? "at most" : "exactly", + max_argc, + min_argc < max_argc? "allowed" : "required", + lpr->num_inputs); return -E_LLS_BAD_ARG_COUNT; } return 1; -- 2.39.5