From: Andre Noll Date: Sun, 13 Feb 2022 19:29:52 +0000 (+0100) Subject: Improve error message of lls_check_arg_count(). X-Git-Tag: v1.0.4~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=lopsub.git;a=commitdiff_plain;h=a927190dc47ea0048a482030dccd2981b6310530 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 --- 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;