list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <>
To: nanaya <>
Subject: Re: git grep -F (fixed string) requires matching parenthesis?
Date: Tue, 13 Aug 2019 08:17:33 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Aug 13, 2019 at 03:01:04PM +0900, nanaya wrote:

> I observed this today:
> $ git grep -F '('
> fatal: unmatched parenthesis
> Which doesn't make sense and I believe shouldn't happen.

At first glance this looks like we're feeding a fixed-string pattern to
the regex compiler, which would indeed be a bug.

But I think it's actually happening at a level above that. git-grep
supports multiple patterns, which can be joined with --and, --or, --not,
etc. And they can be grouped with parentheses.

What you're seeing is the argument parser thinking your '(' is part of
the construction of a boolean match formula, and complaining about the
lack of closing ')'. You can use "-e" to make it clear that it's a
pattern (just as you'd need to for a pattern that starts with "-"):

  git grep -F -e '('

So I think everything is working as designed, though I admit the
implication was slightly surprising to me (and note that it only happens
with that _specific_ pattern; something like "(foo" would not be matched
by the option parser).


  reply	other threads:[~2019-08-13 12:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13  6:01 nanaya
2019-08-13 12:17 ` Jeff King [this message]
2019-08-13 12:33   ` nanaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \
    --subject='Re: git grep -F (fixed string) requires matching parenthesis?' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).