bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xargs: better error message for xargs -s notanumber.


From: Bernhard Voelker
Subject: Re: [PATCH] xargs: better error message for xargs -s notanumber.
Date: Sun, 24 Jan 2016 23:19:53 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 01/24/2016 10:17 PM, James Youngman wrote:
> * xargs/xargs.c (parse_num): Specify the value passed for the
> invalid argument to make it easier to debug things when bug
> reports don't specify the actual command line.
> ---
>  xargs/xargs.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/xargs/xargs.c b/xargs/xargs.c
> index 18393cd..fd9b313 100644
> --- a/xargs/xargs.c
> +++ b/xargs/xargs.c
> @@ -1610,15 +1610,15 @@ parse_num (char *str, int option, long int min, long 
> int max, int fatal)
>    val = strtol (str, &eptr, 10);
>    if (eptr == str || *eptr)
>      {
> -      fprintf (stderr, _("%s: invalid number for -%c option\n"),
> -            program_name, option);
> +      fprintf (stderr, _("%s: invalid number \"%s\" for -%c option\n"),
> +            program_name, str, option);
>        usage (stderr);
>        exit (EXIT_FAILURE);
>      }
>    else if (val < min)
>      {
> -      fprintf (stderr, _("%s: value for -%c option should be >= %ld\n"),
> -            program_name, option, min);
> +      fprintf (stderr, _("%s: value %s for -%c option should be >= %ld\n"),
> +            program_name, str, option, min);
>        if (fatal)
>       {
>         usage (stderr);
> @@ -1631,8 +1631,8 @@ parse_num (char *str, int option, long int min, long 
> int max, int fatal)
>      }
>    else if (max >= 0 && val > max)
>      {
> -      fprintf (stderr, _("%s: value for -%c option should be <= %ld\n"),
> -            program_name, option, max);
> +      fprintf (stderr, _("%s: value %s for -%c option should be <= %ld\n"),
> +            program_name, str, option, max);
>        if (fatal)
>       {
>         usage (stderr);
> 

Nice one!

Nevertheless, the user will maybe still miss that line,
because of the following big usage message.
What about something like the following - shorter ?

  $  xargs/xargs -s ABC
  xargs/xargs: invalid number "ABC" for -s option
  Try 'xargs/xargs --help' for more information.

The attached patch is a draft to do this (on top of your patch).

Have a nice day,
Berny

Attachment: 0001-xargs-emit-a-short-hint-to-help-rather-than-full-usa.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]