Subject: Re: [PATCH v2] setup: update error message to be more meaningful

From: Junio C Hamano <[email-masked]>
Date: Tue, 03 Oct 2017 09:32:21 +0900

Kaartic Sivaraam <[email-masked]> writes:

> Incorrect case,
>
>         $ git grep "some random regex" -n
>         fatal: bad flag '-n' used after filename
>
> The above case is incorrect as "some random regex" isn't a filename
> in this case.

The command line rule is to have dashed options first and then other
arguments, so I agree that "option '-n' used after non-option
argument(s)" would be a better alternative.

"grep" is an oddball, as it allows you to be lazy and omit the "-e"
option when there is only one pattern, making a perfectly reasonable
"grep -e regex -n" into an invalid "grep regex -n".

As an aside, I wonder if we want to _() the message.  It's outside
the scope of this fix, obviously.

>  setup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/setup.c b/setup.c
> index 860507e1f..09c793282 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -230,7 +230,7 @@ void verify_filename(const char *prefix,
>  		     int diagnose_misspelt_rev)
>  {
>  	if (*arg == '-')
> -		die("bad flag '%s' used after filename", arg);
> +		die("option '%s' must come before non-option arguments", arg);
>  	if (looks_like_pathspec(arg) || check_filename(prefix, arg))
>  		return;
>  	die_verify_filename(prefix, arg, diagnose_misspelt_rev);