git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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);
Previous: Kaartic SivaraamNext: Kaartic Sivaraam
Message 14 of 15 in “setup: update error message to be more meaningful”
  1. setup: update error message to be more meaningfulKaartic Sivaraam, Jul 25, 2017
  2. Kaartic SivaraamJul 25, 2017
  3. Jonathan NiederJul 25, 2017
  4. Kaartic SivaraamJul 26, 2017
  5. Junio C HamanoJul 26, 2017
  6. Kaartic SivaraamJul 29, 2017
  7. Junio C HamanoJul 29, 2017
  8. Kaartic SivaraamJul 29, 2017
  9. setup: update error message to be more meaningfulKaartic Sivaraam, Jul 29, 2017
  10. Junio C HamanoJul 29, 2017
  11. Kaartic SivaraamJul 30, 2017
  12. Kaartic SivaraamJul 30, 2017
  13. setup: update error message to be more meaningfulKaartic Sivaraam, Oct 2, 2017
  14. Junio C HamanoOct 3, 2017
  15. Kaartic SivaraamOct 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.