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

Re: git grep argument parser bug

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 5, 2016, 00:22 UTC
Message-ID
<CACsJy8DCn9z2hbodqFw7bL=JDwV8LfFiv52Bk__UO5y8nfcm-A@mail.gmail.com>
In-Reply-To
<CANzEV58SgS6P_qBequGSfA0vFy9s0-KM3xOFaU2DDz_S3OyN3g@mail.gmail.com>
On Fri, Feb 5, 2016 at 5:02 AM, Dylan Grafmyre <dylang@conversica.com> wrote:
> In both ubuntu versions of git 1.9.1 and 2.7.0
>
>     git grep '-test'
>     git grep '--help'

(Un)Quoting is done by shell and stripped out before "git" is executed. We just don't see them.

Show 11 quoted lines
> Or any other expressions literal leading with a single dash or double
> dash get interpreted as argument flags and not as search expressions.
>
> What I expect is grep results for the literal strings "-test" and "--help"
> What i get is git help output informing of wrong argument usage, or
> accidentally turning on flags I didn't expect.
>
> Work around; for afflicted users terminating argument parsing with `
> -- ` works as it should.
>
>     git grep -- '-test'

Or you can do "git grep -e --test". UNIX grep faces the same problem, and also has -e to deal with it.

> Confirmed on two Ubuntu [based] systems, Ubuntu Server 14.03 and
> LinuxMint 17.3 [Cinnamon]
-- 
Duy
Previous: Junio C Hamano
Message 3 of 3 in “git grep argument parser bug”
  1. Dylan GrafmyreFeb 4, 2016
  2. Junio C HamanoFeb 4, 2016
  3. Duy NguyenFeb 5, 2016

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.