]> git.tue.mpg.de Git - lopsub.git/commitdiff
Improve error message of lls_check_arg_count().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 13 Feb 2022 19:29:52 +0000 (20:29 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Jun 2023 14:28:06 +0000 (16:28 +0200)
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

index a9e401f259f63422e3db094080cc66ecb808c694..cbf6661e4cca15652517439272ac2639a19d3d8c 100644 (file)
--- 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;