* git grep argument parser bug
@ 2016-02-04 22:02 Dylan Grafmyre
2016-02-04 22:18 ` Junio C Hamano
2016-02-05 0:22 ` Duy Nguyen
0 siblings, 2 replies; 3+ messages in thread
From: Dylan Grafmyre @ 2016-02-04 22:02 UTC (permalink / raw)
To: git
In both ubuntu versions of git 1.9.1 and 2.7.0
git grep '-test'
git grep '--help'
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'
Confirmed on two Ubuntu [based] systems, Ubuntu Server 14.03 and
LinuxMint 17.3 [Cinnamon]
--
Dylan Grafmyre
Associate System Administrator
Email: DylanG@conversica.com
Office: +1 (888) 778 1004
Web: www.conversica.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git grep argument parser bug
2016-02-04 22:02 git grep argument parser bug Dylan Grafmyre
@ 2016-02-04 22:18 ` Junio C Hamano
2016-02-05 0:22 ` Duy Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2016-02-04 22:18 UTC (permalink / raw)
To: Dylan Grafmyre; +Cc: git
Dylan Grafmyre <dylang@conversica.com> writes:
> In both ubuntu versions of git 1.9.1 and 2.7.0
>
> git grep '-test'
> git grep '--help'
>
> 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"
I think you'd need to adjust your expectations, then ;-).
This is how "grep" (not "git grep") works, and you use "-e", i.e.
grep -e "-anything that begins with a dash" FILES...
to disambiguate. If you are scripting, if you do not know what you
have in a variable, and if you are looking for the value in that
variable, you would always do
grep -e "$variable" FILES...
not
grep "$variable" FILES...
I think all of the above is pretty much the standard practice and
"git grep" merely follows suit, i.e.
git grep -e "-help"
is designed to work that way to match users' expectations.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git grep argument parser bug
2016-02-04 22:02 git grep argument parser bug Dylan Grafmyre
2016-02-04 22:18 ` Junio C Hamano
@ 2016-02-05 0:22 ` Duy Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Duy Nguyen @ 2016-02-05 0:22 UTC (permalink / raw)
To: Dylan Grafmyre; +Cc: Git Mailing List
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.
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-05 0:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04 22:02 git grep argument parser bug Dylan Grafmyre
2016-02-04 22:18 ` Junio C Hamano
2016-02-05 0:22 ` Duy Nguyen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.