beyondgrep / ack2

**ack 2 is no longer being maintained. ack 3 is the latest version.**
https://github.com/beyondgrep/ack3/
Other
1.48k stars 140 forks source link

ack-grep:<num>: command not found: <expr> #612

Closed xh3b4sd closed 8 years ago

xh3b4sd commented 8 years ago

I found a way to make ack-grep unusable.

vagrant@xenial ack-grep --version
ack 2.14
Running under Perl 5.22.1 at /usr/bin/perl

Copyright 2005-2014 Andy Lester.

This program is free software.  You may modify or distribute it
under the terms of the Artistic License v2.0.
vagrant@xenial ack-grep Foo().Bar
vagrant@xenial ack-grep
ack-grep:2: command not found: .Bar
vagrant@xenial ack-grep --version
ack-grep:3: command not found: .Bar

When reloading my terminal session ack-grep is back to normal again, but can be brought into the described unhealthy state again. The malicious expression is <A>().<B>. Thus Cat().Dog causes ack-grep to fail as well. I am on a Vagrant box.

vagrant@xenial uname -a
Linux xenial 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
vagrant@xenial cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"
petdance commented 8 years ago

Thanks for the report.

It sounds to me like something weird in your shell. What shell are you running? When I run ack like that I get:

$ ack Foo().Bar
-bash: syntax error near unexpected token `('

And it doesn't matter if it's ack.

$ ls Foo().Bar
-bash: syntax error near unexpected token `('
$ tar Foo().Bar
-bash: syntax error near unexpected token `('

What happens when you quote the arguments, as in:

ack 'Foo().Bar'
xh3b4sd commented 8 years ago

Thanks for coming back that quickly. It is indeed weird. I am on zsh and the issue is not ack-grep as it looks like.

vagrant@xenial zsh --version
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)
vagrant@xenial tar Foo().Bar
vagrant@xenial tar
tar:4: command not found: .Bar

I will check back with the z-shell folks.

mcornella commented 8 years ago

That's actually what you said, a lack of quoting of parenthesis which are interpreted as defining a function. The solution then is quote everything: https://github.com/robbyrussell/oh-my-zsh/issues/5490#issuecomment-251251476. You can close this one.