Re: [PATCH v2] setup: update error message to be more meaningful
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 3, 2017, 00:32 UTC
- Message-ID
- <xmqq7ewdm5pm.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20171002173002.4278-1-kaarticsivaraam@gmail.com>
Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
Show 7 quoted lines
> 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.
Show 16 quoted lines
> 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);