ack 1.96 chokes on literal pattern

34 views
Skip to first unread message

Raffaele Ricciardi

unread,
Aug 1, 2012, 10:24:50 AM8/1/12
to ack-...@googlegroups.com
Hello everybody,

ack 1.96 rejects a literal pattern when it starts with +.

Example:

ack -G \.*.el$ -Q +test+

Bug or misuse?

Thanks.


Rob Hoelz

unread,
Aug 1, 2012, 10:28:43 AM8/1/12
to ack-...@googlegroups.com
Hi Raffaele!

Thanks for your input on ack!  Have you tried putting a '--' before the +test+ pattern?

-Rob

Andy Lester

unread,
Aug 1, 2012, 10:36:20 AM8/1/12
to ack-...@googlegroups.com

On Aug 1, 2012, at 9:28 AM, Rob Hoelz wrote:

Thanks for your input on ack!  Have you tried putting a '--' before the +test+ pattern?

More detail: Rob is thinking that ack is seeing "+test+" as a command line option because of the leading plus.  Putting a "--" on the command line says "nothing after here is a command line switch, even if it looks like it is."

I've made a note to make this be an FAQ. https://github.com/petdance/ack2/issues/140

Thanks!

xoa

Raffaele Ricciardi

unread,
Aug 1, 2012, 2:31:33 PM8/1/12
to ack-...@googlegroups.com
That fixed the issue.  Thanks Rob. And thanks Andy for your explanation.

Raffaele Ricciardi

unread,
Aug 3, 2012, 3:48:00 PM8/3/12
to ack-...@googlegroups.com
On Wednesday, August 1, 2012 3:36:20 PM UTC+1, Andy Lester wrote:
>    I've made a note to make this be an FAQ. https://github.com/petdance/ack2/issues/140

However, I think such an issue would be better mentioned in the --help of Ack.  I don't remember having ever dealt with programs using + for arguments, and so may have never done other users as well.

A + at the beginning of an argument could be even caught by Ack itself, and a warning issued, before passing arguments to GetOpt.

I've also found another workaround: using --match to explicitly specify the pattern, but then + must be escaped.

Have a nice day.

Andy Lester

unread,
Aug 3, 2012, 3:51:42 PM8/3/12
to ack-...@googlegroups.com

On Aug 3, 2012, at 2:48 PM, Raffaele Ricciardi wrote:

A + at the beginning of an argument could be even caught by Ack itself, and a warning issued, before passing arguments to GetOpt.

I've also found another workaround: using --match to explicitly specify the pattern, but then + must be escaped.

Or should we just tell Getopt::Long to disallow + as a prefix for options?

Will Coleda

unread,
Aug 3, 2012, 4:39:59 PM8/3/12
to ack-...@googlegroups.com
On Fri, Aug 3, 2012 at 3:51 PM, Andy Lester <an...@petdance.com> wrote:
>
> On Aug 3, 2012, at 2:48 PM, Raffaele Ricciardi wrote:
>
> A + at the beginning of an argument could be even caught by Ack itself, and
> a warning issued, before passing arguments to GetOpt.
>
> I've also found another workaround: using --match to explicitly specify the
> pattern, but then + must be escaped.
>
>
> Or should we just tell Getopt::Long to disallow + as a prefix for options?
>
> xoa

+1 from me on this.

> --
> Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance
>
> --
> You received this message because you are subscribed to the Google Groups
> "ack dev/users" group.
> To post to this group, send email to ack-...@googlegroups.com.
> To unsubscribe from this group, send email to
> ack-users+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ack-users?hl=en.



--
Will "Coke" Coleda

Rob Hoelz

unread,
Aug 3, 2012, 4:55:41 PM8/3/12
to ack-...@googlegroups.com
On Fri, 3 Aug 2012 16:39:59 -0400
Will Coleda <wi...@coleda.com> wrote:

> On Fri, Aug 3, 2012 at 3:51 PM, Andy Lester <an...@petdance.com> wrote:
> >
> > On Aug 3, 2012, at 2:48 PM, Raffaele Ricciardi wrote:
> >
> > A + at the beginning of an argument could be even caught by Ack
> > itself, and a warning issued, before passing arguments to GetOpt.
> >
> > I've also found another workaround: using --match to explicitly
> > specify the pattern, but then + must be escaped.
> >
> >
> > Or should we just tell Getopt::Long to disallow + as a prefix for
> > options?
> >
> > xoa
>
> +1 from me on this.

+1 from me as well.
signature.asc

Andy Lester

unread,
Aug 3, 2012, 4:57:34 PM8/3/12
to ack-...@googlegroups.com
On Aug 3, 2012, at 3:55 PM, Rob Hoelz wrote:

Or should we just tell Getopt::Long to disallow + as a prefix for
options?

+1 from me on this.

+1 from me as well.

Well, duh, it was your idea. :-)

Bill Ricker

unread,
Aug 3, 2012, 8:29:55 PM8/3/12
to ack-...@googlegroups.com
On Fri, Aug 3, 2012 at 3:51 PM, Andy Lester <an...@petdance.com> wrote:
Or should we just tell Getopt::Long to disallow + as a prefix for options?

As an option when not in use, sure. 

There are plenty of programs that use +x  as the opposite of -x (as with shell usage), predating the --no-verbose-name standard , so it can't be obliterated.

--
Bill
@n1vux bill....@gmail.com

Andrew Black

unread,
Aug 4, 2012, 7:48:34 AM8/4/12
to ack-...@googlegroups.com
On 4 August 2012 01:29, Bill Ricker <bill....@gmail.com> wrote:
There are plenty of programs that use +x  as the opposite of -x (as with shell usage), predating the --no-verbose-name standard , so it can't be obliterated.

I am not sure that +options are really useful in ack context.  Ack doesn't advertise that you can use then ,so I can't see much harm in removing it.

So in summary it is "+1" from me

 

Rob Hoelz

unread,
Aug 4, 2012, 8:23:41 AM8/4/12
to ack-...@googlegroups.com
Funny, "ack +1" should work ok :)
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Andrew Black <andrew...@googlemail.com> wrote:
--

Bill Ricker

unread,
Aug 4, 2012, 2:36:24 PM8/4/12
to ack-...@googlegroups.com
I am not sure that +options are really useful in ack context.  Ack doesn't advertise that you can use then ,so I can't see much harm in removing it.

Agreed. My point was addressed to possible misinterpretation of suggestion that Getopt excise them totally. Disabling them by meta config for Ack is good. Disabling them for other perl programs that do use them bad.

 
--
Bill
@n1vux bill....@gmail.com
Reply all
Reply to author
Forward
0 new messages