Inverse filename matching

1 view
Skip to first unread message

Bob Farrell

unread,
Apr 17, 2009, 9:52:27 AM4/17/09
to ack dev/users
Hi,

ack makes me happy, but I can't figure out how to do an inverse match
for filenames. I'd like to be able to specify in my rc file something
like this:

--ignore -min.js$

Is this possible already ? I tried this:

-G (?!-min.js$)

But perhaps I'm doing something wrong.

Thanks for any help. :)

Andy Lester

unread,
Apr 17, 2009, 11:56:56 AM4/17/09
to ack-...@googlegroups.com

On Apr 17, 2009, at 8:52 AM, Bob Farrell wrote:

>
> Hi,
>
> ack makes me happy, but I can't figure out how to do an inverse match
> for filenames. I'd like to be able to specify in my rc file something
> like this:

No, there isn't, but that's a good idea.

--
Andy Lester => an...@petdance.com => www.theworkinggeek.com => AIM:petdance


Bob Farrell

unread,
Apr 17, 2009, 2:26:13 PM4/17/09
to ack dev/users
Hi,

Here's a patch. I haven't written Perl in years so it was a bit of a
headache, but I've tested it and can't find any issues with it.

(Sorry I didn't attach it as a file, I'm using this weird Google thing
and I can't figure out how to do it).

85c85
< App::Ack::check_regex( $_ ) for ( $opt->{regex}, $opt->{G}, $opt-
>{X} );
---
> App::Ack::check_regex( $_ ) for ( $opt->{regex}, $opt->{G} );
1174,1175d1173
< 'x=s' => sub { shift; $opt{X} = shift; $opt
{f} = 1 },
< 'X=s' => \$opt{X},
1626d1623
< -x REGEX Same as -f, but exclude files matching
REGEX.
1636d1632
< -X REGEX Exclude files that match REGEX
2208d2203
< my $x_regex = defined $opt->{X} ? qr/$opt->{X}/ : undef;
2218,2224d2212
< elsif ( $x_regex ) {
< $file_filter
< = $opt->{u} ? sub { $File::Next::name !~ /$x_regex/ }
# XXX Maybe this should be a 1, no?
< : $opt->{all} ? sub { $starting_point
{ $File::Next::name } || ( $File::Next::name !~ /$x_regex/ &&
is_searchable( $File::Next::name ) ) }
< : sub { $starting_point
{ $File::Next::name } || ( $File::Next::name !~ /$x_regex/ &&
is_interesting( @_ ) ) }
< ;
< }


On Apr 17, 4:56 pm, Andy Lester <a...@petdance.com> wrote:
> On Apr 17, 2009, at 8:52 AM, Bob Farrell wrote:
>
>
>
> > Hi,
>
> > ack makes me happy, but I can't figure out how to do an inverse match
> > for filenames. I'd like to be able to specify in my rc file something
> > like this:
>
> No, there isn't, but that's a good idea.
>
> --
> Andy Lester => a...@petdance.com =>www.theworkinggeek.com=> AIM:petdance
Reply all
Reply to author
Forward
0 new messages