support -e to specify pattern

Bug #591233 reported by Brian de Alwis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bzr-grep
Confirmed
Wishlist
Unassigned

Bug Description

It would be most excellent if bzr-grep supported a '-e' switch to explicitly specify the pattern.

I recently had to back out to using plain grep as my pattern began with a '-' and so was being interpreted for a switch.

Revision history for this message
Parth Malwankar (parthm) wrote :

Hi Brian,

Escaping "-" seems to allows the patterns starting with "-" to be searched. E.g.

[grep]% bzr grep "\-grep"
INSTALL:'bzr-grep' is a bazaar plugin so you need to install it
INSTALL: $ bzr branch lp:bzr-grep ~/.bazaar/plugins/grep
INSTALL: $ mv bzr-grep ~/.bazaar/plugins/grep

Is the above behavior suitable to cover your use case or are there
some other common cases that we need to cover? I ask as I haven't
used -e before and grep man page wasn't very helpful with examples.

[1] http://docs.python.org/library/re.html#regular-expression-syntax

Revision history for this message
Brian de Alwis (slyguy) wrote : Re: [Bug 591233] Re: support -e to specify pattern

> Escaping "-" seems to allows the patterns starting with "-" to be
> searched.

That's a nifty workaround. I would still recommend adding -e: it's the
standard mechanism that most Unix savvy non-Pythoners would expect.

BTW: thanks for your work on bzr-grep. It's been far more useful than
I anticipated.

Revision history for this message
Parth Malwankar (parthm) wrote :

I agree. Having standard behavior is good. I check if bzrlib command line option processing supports (or can be enhanced) for this.

Changed in bzr-grep:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian de Alwis wrote:
>> Escaping "-" seems to allows the patterns starting with "-" to be
>> searched.
>
> That's a nifty workaround. I would still recommend adding -e: it's the
> standard mechanism that most Unix savvy non-Pythoners would expect.
>
> BTW: thanks for your work on bzr-grep. It's been far more useful than
> I anticipated.
>

I'm also pretty sure that:

bzr grep -- "-pattern"

Should work just fine. and "--" is the standard "end of option flags"
argument.

I don't really care whether or not it takes '-e'.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwPt8QACgkQJdeBCYSNAANvfwCeM7tflBzNngzS6o3jzsjtPS7X
39oAn2IaHfdpA9Y/yCheVx7+18BoykSY
=hgO2
-----END PGP SIGNATURE-----

Revision history for this message
Colin D Bennett (colinb) wrote :

Yes,

bzr grep -- "-pattern"

does work. The "-e PATTERN" option could be added but is not necessary since the standard "--" works already. Unless the POSIX grep "-f FILE" option was added too, in order to read patterns from the file FILE: then a "-e PATTERN" would be a good addition.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.