Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

1.90 is latest

  • Loading branch information...
commit d64b5b83024be8067fe39f6173552997d11afb99 2 parents 5a2aef2 + 34d0319
petdance authored
View
119 Ack.pm
@@ -13,14 +13,14 @@ App::Ack - A container for functions for the ack program
=head1 VERSION
-Version 1.88
+Version 1.90
=cut
our $VERSION;
our $COPYRIGHT;
BEGIN {
- $VERSION = '1.88';
+ $VERSION = '1.90';
$COPYRIGHT = 'Copyright 2005-2009 Andy Lester, all rights reserved.';
}
@@ -36,10 +36,12 @@ our %type_wanted;
our %mappings;
our %ignore_dirs;
+our $input_from_pipe;
+our $output_to_pipe;
+
our $dir_sep_chars;
our $is_cygwin;
our $is_windows;
-our $to_screen;
use File::Spec ();
use File::Glob ':glob';
@@ -70,6 +72,7 @@ BEGIN {
%mappings = (
actionscript => [qw( as mxml )],
+ ada => [qw( ada adb ads )],
asm => [qw( asm s )],
batch => [qw( bat cmd )],
binary => q{Binary files, as defined by Perl's -B op (default: off)},
@@ -101,7 +104,7 @@ BEGIN {
python => [qw( py )],
rake => q{Rakefiles},
ruby => [qw( rb rhtml rjs rxml erb rake )],
- scheme => [qw( scm )],
+ scheme => [qw( scm ss )],
shell => [qw( sh bash csh tcsh ksh zsh )],
skipped => q{Files, but not directories, normally skipped by ack (default: off)},
smalltalk => [qw( st )],
@@ -124,10 +127,13 @@ BEGIN {
}
}
- $is_cygwin = ($^O eq 'cygwin');
- $is_windows = ($^O =~ /MSWin32/);
- $to_screen = -t *STDOUT;
- $dir_sep_chars = $is_windows ? quotemeta( '\\/' ) : quotemeta( File::Spec->catfile( '', '' ) );
+ # These have to be checked before any filehandle diddling.
+ $output_to_pipe = not -t *STDOUT;
+ $input_from_pipe = -p STDIN;
+
+ $is_cygwin = ($^O eq 'cygwin');
+ $is_windows = ($^O =~ /MSWin32/);
+ $dir_sep_chars = $is_windows ? quotemeta( '\\/' ) : quotemeta( File::Spec->catfile( '', '' ) );
}
=head1 SYNOPSIS
@@ -189,6 +195,9 @@ sub get_command_line_options {
'break!' => \$opt{break},
c => \$opt{count},
'color|colour!' => \$opt{color},
+ 'color-match=s' => \$ENV{ACK_COLOR_MATCH},
+ 'color-filename=s' => \$ENV{ACK_COLOR_FILENAME},
+ 'column!' => \$opt{column},
count => \$opt{count},
'env!' => sub { }, # ignore this option, it is handled beforehand
f => \$opt{f},
@@ -203,10 +212,10 @@ sub get_command_line_options {
'i|ignore-case' => \$opt{i},
'lines=s' => sub { shift; my $val = shift; push @{$opt{lines}}, $val },
'l|files-with-matches' => \$opt{l},
- 'L|files-without-match' => sub { $opt{l} = $opt{v} = 1 },
+ 'L|files-without-matches' => sub { $opt{l} = $opt{v} = 1 },
'm|max-count=i' => \$opt{m},
'match=s' => \$opt{regex},
- n => \$opt{n},
+ 'n|no-recurse' => \$opt{n},
o => sub { $opt{output} = '$&' },
'output=s' => \$opt{output},
'pager=s' => \$opt{pager},
@@ -214,6 +223,7 @@ sub get_command_line_options {
'passthru' => \$opt{passthru},
'print0' => \$opt{print0},
'Q|literal' => \$opt{Q},
+ 'r|R|recurse' => sub {},
'smart-case!' => \$opt{smart_case},
'sort-files' => \$opt{sort_files},
'u|unrestricted' => \$opt{u},
@@ -260,6 +270,7 @@ sub get_command_line_options {
$parser->getoptions( %{$getopt_specs} ) or
App::Ack::die( 'See ack --help or ack --man for options.' );
+ my $to_screen = not output_to_pipe();
my %defaults = (
all => 0,
color => $to_screen,
@@ -464,8 +475,9 @@ sub filetypes {
my $basename = $filename;
$basename =~ s{.*[$dir_sep_chars]}{};
- return ('make',TEXT) if lc $basename eq 'makefile';
- return ('rake','ruby',TEXT) if lc $basename eq 'rakefile';
+ my $lc_basename = lc $basename;
+ return ('make',TEXT) if $lc_basename eq 'makefile';
+ return ('rake','ruby',TEXT) if $lc_basename eq 'rakefile';
# If there's an extension, look it up
if ( $filename =~ m{\.([^\.$dir_sep_chars]+)$}o ) {
@@ -681,8 +693,8 @@ Search output:
--line=NUM Only print line(s) NUM of each file
-l, --files-with-matches
Only print filenames containing matches
- -L, --files-without-match
- Only print filenames with no match
+ -L, --files-without-matches
+ Only print filenames with no matches
-o Show only the part of a line matching PATTERN
(turns off text highlighting)
--passthru Print all lines, whether matching or not
@@ -694,6 +706,7 @@ Search output:
-H, --with-filename Print the filename for each match
-h, --no-filename Suppress the prefixing filename on output
-c, --count Show number of lines matching per file
+ --column Show the column number of the first match
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching
@@ -708,8 +721,8 @@ Search output:
only works with -f, -g, -l, -L or -c.
File presentation:
- --pager=COMMAND Pipes all ack output through COMMAND.
- Ignored if output is redirected.
+ --pager=COMMAND Pipes all ack output through COMMAND. For example,
+ --pager="less -R". Ignored if output is redirected.
--nopager Do not send output through a pager. Cancels any
setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR.
--[no]heading Print a filename heading above each file's results.
@@ -721,6 +734,8 @@ File presentation:
--[no]color Highlight the matching text (default: on unless
output is redirected, or on Windows)
--[no]colour Same as --[no]color
+ --color-filename=COLOR
+ --color-match=COLOR Set the color for matches and filenames.
--flush Flush output immediately, even when ack is used
non-interactively (when output goes to a pipe or
file).
@@ -736,7 +751,8 @@ File inclusion/exclusion:
Ignores CVS, .svn and other ignored directories
-u, --unrestricted All files and directories searched
--[no]ignore-dir=name Add/Remove directory from the list of ignored dirs
- -n No descending into subdirectories
+ -r, -R, --recurse Recurse into subdirectories (ack's default behavior)
+ -n, --no-recurse No descending into subdirectories
-G REGEX Only search files that match REGEX
--perl Include only Perl files.
@@ -838,14 +854,25 @@ Returns the version information for ack.
=cut
sub get_version_statement {
+ require Config;
+
my $copyright = get_copyright();
+ my $this_perl = $Config::Config{perlpath};
+ if ($^O ne 'VMS') {
+ my $ext = $Config::Config{_exe};
+ $this_perl .= $ext unless $this_perl =~ m/$ext$/i;
+ }
+ my $ver = sprintf( '%vd', $^V );
+
return <<"END_OF_VERSION";
ack $VERSION
+Running under Perl $ver at $this_perl
$copyright
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
+This program is free software; you can redistribute it and/or modify
+it under the terms of either: the GNU General Public License as
+published by the Free Software Foundation; or the Artistic License.
END_OF_VERSION
}
@@ -922,6 +949,7 @@ sub print_blank_line { App::Ack::print( "\n" ) }
sub print_separator { App::Ack::print( "--\n" ) }
sub print_filename { App::Ack::print( $_[0], $_[1] ) }
sub print_line_no { App::Ack::print( $_[0], $_[1] ) }
+sub print_column_no { App::Ack::print( $_[0], $_[1] ) }
sub print_count {
my $filename = shift;
my $nmatches = shift;
@@ -1010,7 +1038,7 @@ sub search_resource {
if ( $keep_context ) {
if ( $after ) {
- print_match_or_context( $opt, 0, $., $_ );
+ print_match_or_context( $opt, 0, $., $-[0], $+[0], $_ );
$after--;
}
elsif ( $before_context ) {
@@ -1045,7 +1073,7 @@ sub search_resource {
}
if ( $keep_context ) {
if ( @before ) {
- print_match_or_context( $opt, 0, $before_starts_at_line, @before );
+ print_match_or_context( $opt, 0, $before_starts_at_line, $-[0], $+[0], @before );
@before = ();
$before_starts_at_line = 0;
}
@@ -1056,7 +1084,7 @@ sub search_resource {
$after = $after_context;
}
}
- print_match_or_context( $opt, 1, $., $_ );
+ print_match_or_context( $opt, 1, $., $-[0], $+[0], $_ );
last if $max && ( $nmatches >= $max ) && !$after;
} # while
@@ -1065,20 +1093,23 @@ sub search_resource {
} # search_resource()
-=head2 print_match_or_context( $opt, $is_match, $starting_line_no, @lines )
+=head2 print_match_or_context( $opt, $is_match, $starting_line_no, $match_start, $match_end, @lines )
Prints out a matching line or a line of context around a match.
=cut
sub print_match_or_context {
- my $opt = shift; # opts array
- my $is_match = shift; # is there a match on the line?
- my $line_no = shift;
-
- my $color = $opt->{color};
- my $heading = $opt->{heading};
+ my $opt = shift; # opts array
+ my $is_match = shift; # is there a match on the line?
+ my $line_no = shift;
+ my $match_start = shift;
+ my $match_end = shift;
+
+ my $color = $opt->{color};
+ my $heading = $opt->{heading};
my $show_filename = $opt->{show_filename};
+ my $show_column = $opt->{column};
if ( $show_filename ) {
if ( not defined $display_filename ) {
@@ -1125,6 +1156,9 @@ sub print_match_or_context {
# remove any kind of newline at the end of the line
s/[\r\n]*\z//;
}
+ if ( $show_column ) {
+ App::Ack::print_column_no( $match_start+1, $sep );
+ }
App::Ack::print($_ . "\n");
}
$any_output = 1;
@@ -1261,7 +1295,8 @@ sub print_matches {
my $nmatches = 0;
while ( defined ( my $filename = $iter->() ) ) {
my $repo;
- if ( $filename =~ /\.tar\.gz$/ ) {
+ my $tarballs_work = 0;
+ if ( $tarballs_work && $filename =~ /\.tar\.gz$/ ) {
App::Ack::die( 'Not working here yet' );
require App::Ack::Repository::Tar; # XXX Error checking
$repo = App::Ack::Repository::Tar->new( $filename );
@@ -1438,7 +1473,7 @@ sub get_iterator {
sub set_up_pager {
my $command = shift;
- return unless $to_screen;
+ return unless App::Ack::output_to_pipe();
my $pager;
if ( not open( $pager, '|-', $command ) ) {
@@ -1449,6 +1484,28 @@ sub set_up_pager {
return;
}
+=head2 input_from_pipe()
+
+Returns true if ack's input is coming from a pipe.
+
+=cut
+
+sub input_from_pipe {
+ return $input_from_pipe;
+}
+
+
+=head2 output_to_pipe()
+
+Returns true if ack's input is coming from a pipe.
+
+=cut
+
+sub output_to_pipe {
+ return $output_to_pipe;
+}
+
+
=head1 COPYRIGHT & LICENSE
Copyright 2005-2009 Andy Lester, all rights reserved.
View
64 Changes
@@ -1,5 +1,69 @@
Changelog for ack
+1.90 Mon Sep 7 23:24:24 CDT 2009
+ [ENHANCEMENTS]
+ Added Ada support. Thanks to Shaun Patterson.
+
+ Added -r, -R and --recurse options as in grep. They have no
+ effect because directory recursion is on by default. Also added
+ --no-recurse for orthoganality. Thanks to Mark Stosberg and
+ Ryan Niebur.
+
+ Version in --version is prettier. Thanks, Ori Avtalion.
+
+ Added an updated ack.bash_completion.sh from Adam James.
+
+ [FIXES]
+ Expanded --files-without-match to --files-without-matches.
+
+ Removed all the hi-bit characters, so we don't have any encoding
+ problems. It's all entities now.
+
+ Fixed capture-stderr to localize some globals that were obscuring
+ errors. Thanks very much to Christopher Madsen.
+
+ Fixed uninitialized errors in tickets #138 and #159.
+
+ [DOCUMENTATION]
+ Fixed an incorrect command line in the docs for -f.
+
+ Added notes on --pager. Thanks to Mike Morearty.
+
+ [BUILD]
+ Made the squash program more robust when handling POD. Thanks
+ to Kent Fredric.
+
+
+1.89_02 Wed May 13 16:20:21 CDT 2009
+ [DISTRIBUTION]
+ Updated Makefile.PL to use new ExtUtils::MakeMaker features.
+ Thanks, Schwern.
+
+ [FEATURES]
+ --version now shows the version of Perl that ack is running
+ under, and the full path to the Perl executable.
+
+ Added new switches --color-match and --color-filename, which
+ let you define ACK_COLOR_MATCH and ACK_COLOR_FILENAME from the
+ command line.
+
+ Added new switch --column to display the column of the first
+ hit on the row. Thanks to Eric Van Dewoestine.
+
+ Added .ss to --scheme.
+
+ [FIXES]
+ No longer die if you have a .tar.gz file in your tree.
+
+ More tweaks to get the detection of input and output pipes
+ working.
+
+ Fixed an amazingly bad call to cmp_ok() in t/ack-passthru.t.
+
+ [DOCUMENTATION]
+ Started an ack FAQ.
+
+
1.88 Sat Feb 7 13:51:35 CST 2009
[BIG CHANGES]
ack-standalone no longer exists. ack is now built from ack-base.
View
4 MANIFEST
@@ -7,7 +7,6 @@ Resource.pm
Changes
MANIFEST
Makefile.PL
-META.yml
README
ack
ack-base
@@ -25,6 +24,7 @@ t/ack-a.t
t/ack-binary.t
t/ack-c.t
t/ack-color.t
+t/ack-column.t
t/ack-env.t
t/ack-g.t
t/ack-group.t
@@ -43,6 +43,7 @@ t/ack-w.t
t/code.t
t/command-line-files.t
t/context.t
+t/encoding.t
t/filetypes.t
t/file-permission.t
t/illegal-regex.t
@@ -121,6 +122,7 @@ t/swamp/perl.cgi
t/swamp/perl.pl
t/swamp/perl.pm
t/swamp/perl.pod
+t/swamp/perl.tar.gz
t/swamp/Rakefile
t/swamp/sample.rake
t/swamp/solution8.tar
View
15 META.yml
@@ -1,15 +0,0 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: ack
-version: 1.60
-version_from: Ack.pm
-installdirs: site
-requires:
- File::Basename: 0
- File::Next: 0.4
- Getopt::Long: 0
- Term::ANSIColor: 0
- Test::More: 0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
View
22 Makefile.PL
@@ -27,6 +27,7 @@ my %parms = (
'Test::More' => 0,
'File::Next' => 0.40, # Handle files called "0"
'File::Basename' => 0,
+ 'Pod::Usage' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'ack-1* nytprof*' },
@@ -36,16 +37,17 @@ if ( $ExtUtils::MakeMaker::VERSION =~ /^\d\.\d\d$/ and $ExtUtils::MakeMaker::VER
$parms{LICENSE} = 'perl';
}
-if ( $ExtUtils::MakeMaker::VERSION ge '6.36' ) {
- $parms{EXTRA_META} = <<EOF;
-resources:
- homepage: http://petdance.com/ack/
- bugtracker: http://code.google.com/p/ack/issues/list
- license: http://dev.perl.org/licenses/
- Repository: http://code.google.com/p/ack/source
- MailingList: http://groups.google.com/group/ack-users
-EOF
- }
+if ( $ExtUtils::MakeMaker::VERSION ge '6.46' ) {
+ $parms{META_MERGE} = {
+ resources => {
+ homepage => 'http://betterthangrep.com/',
+ bugtracker => 'http://code.google.com/p/ack/issues/list',
+ license => 'http://dev.perl.org/licenses/',
+ repository => 'http://code.google.com/p/ack/source',
+ MailingList => 'http://groups.google.com/group/ack-users',
+ }
+ };
+}
WriteMakefile( %parms );
View
178 ack
@@ -12,8 +12,8 @@
use warnings;
use strict;
-our $VERSION = '1.88';
-# Check http://petdance.com/ack/ for updates
+our $VERSION = '1.90';
+# Check http://betterthangrep.com/ for updates
# These are all our globals.
@@ -58,7 +58,7 @@ sub main {
$| = 1 if $opt->{flush}; # Unbuffer the output if flush mode
- if ( -p STDIN ) { # Check to see if it's a pipe
+ if ( App::Ack::input_from_pipe() ) {
# We're going into filter mode
for ( qw( f g l ) ) {
$opt->{$_} and App::Ack::die( "Can't use -$_ when acting as a filter." );
@@ -213,6 +213,19 @@ On Windows, this option is off by default unless the
L<Win32::Console::ANSI> module is installed or the C<ACK_PAGER_COLOR>
environment variable is used.
+=item B<--color-filename=I<color>>
+
+Sets the color to be used for filenames.
+
+=item B<--color-match=I<color>>
+
+Sets the color to be used for matches.
+
+=item B<--column>
+
+Show the column number of the first match. This is helpful for editors
+that can place your cursor at a given position.
+
=item B<--env>, B<--noenv>
B<--noenv> disables all environment processing. No F<.ackrc> is read
@@ -573,11 +586,15 @@ Underline and underscore are equivalent, as are clear and reset.
The color alone sets the foreground color, and on_color sets the
background color.
+This option can also be set with B<--color-filename>.
+
=item ACK_COLOR_MATCH
Specifies the color of the matching text when printed in B<--color>
mode. By default, it's "black on_yellow".
+This option can also be set with B<--color-match>.
+
See B<ACK_COLOR_FILENAME> for the color specifications.
=item ACK_PAGER
@@ -680,7 +697,11 @@ list of all the Perl files in a tree, ideal for sending into F<xargs>.
For example:
# Change all "this" to "that" in all Perl files in a tree.
- ack -f --perl | perl -p -i -e's/this/that/g'
+ ack -f --perl | xargs perl -p -i -e's/this/that/g'
+
+or if you prefer:
+
+ perl -p -i -e's/this/thatg/' $(ack -f --perl)
=head2 Use F<-Q> when in doubt about metacharacters
@@ -706,6 +727,20 @@ the previous five lines from the log in each case.
Join the ack-users mailing list. Send me your tips and I may add
them here.
+=head1 FAQ
+
+=head2 Wouldn't it be great if F<ack> did search & replace?
+
+No, ack will always be read-only. Perl has a perfectly good way
+to do search & replace in files, using the C<-i>, C<-p> and C<-n>
+switches.
+
+You can certainly use ack to select your files to update. For
+example, to change all "foo" to "bar" in all PHP files, you can do
+this form the Unix shell:
+
+ $ perl -i -p -e's/foo/bar/g' $(ack -f --php)
+
=head1 AUTHOR
Andy Lester, C<< <andy at petdance.com> >>
@@ -736,7 +771,7 @@ Support for and information about F<ack> can be found at:
=item * The ack homepage
-L<http://petdance.com/ack/>
+L<http://betterthangrep.com/>
=item * The ack issues list at Google Code
@@ -765,6 +800,11 @@ L<http://ack.googlecode.com/svn/>
How appropriate to have I<ack>nowledgements!
Thanks to everyone who has contributed to ack in any way, including
+Ryan Niebur,
+Kent Fredric,
+Mike Morearty,
+Ingmar Vanhassel,
+Eric Van Dewoestine,
Sitaram Chamarty,
Adam James,
Richard Carlsson,
@@ -785,10 +825,10 @@ Kevin Riggle,
Ori Avtalion,
Torsten Blix,
Nigel Metheringham,
-Gábor Szabó,
+GE<aacute>bor SzabE<oacute>,
Tod Hagan,
Michael Hendricks,
-Ævar Arnfjörð Bjarmason,
+E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason,
Piers Cawley,
Stephen Steneker,
Elias Lutfallah,
@@ -803,11 +843,11 @@ Elliot Shank,
Merijn Broeren,
Uwe Voelker,
Rick Scott,
-Ask Bjørn Hansen,
+Ask BjE<oslash>rn Hansen,
Jerry Gay,
Will Coleda,
Mike O'Regan,
-Slaven Rezić,
+Slaven ReziE<0x107>,
Mark Stosberg,
David Alan Pisoni,
Adriano Ferreira,
@@ -818,7 +858,7 @@ and Pete Krawczyk.
=head1 COPYRIGHT & LICENSE
-Copyright 2005-2009 Andy Lester, all rights reserved.
+Copyright 2005-2009 Andy Lester.
This program is free software; you can redistribute it and/or modify
it under the terms of either:
@@ -829,7 +869,7 @@ it under the terms of either:
Software Foundation; either version 1, or (at your option) any later
version, or
-=item * the "Artistic License" which comes with Perl 5.
+=item * the Artistic License version 2.0.
=back
@@ -840,7 +880,7 @@ use strict;
use warnings;
-our $VERSION = '1.02';
+our $VERSION = '1.06';
@@ -866,6 +906,8 @@ BEGIN {
sub files {
+ ($_[0] eq __PACKAGE__) && die 'File::Next::files must not be invoked as File::Next->files';
+
my ($parms,@queue) = _setup( \%files_defaults, @_ );
my $filter = $parms->{file_filter};
@@ -896,8 +938,8 @@ sub files {
-sub sort_standard($$) { return $_[0]->[1] cmp $_[1]->[1] };
-sub sort_reverse($$) { return $_[1]->[1] cmp $_[0]->[1] };
+sub sort_standard($$) { return $_[0]->[1] cmp $_[1]->[1] }
+sub sort_reverse($$) { return $_[1]->[1] cmp $_[0]->[1] }
sub reslash {
my $path = shift;
@@ -966,8 +1008,7 @@ sub _candidate_files {
my $follow_symlinks = $parms->{follow_symlinks};
my $sort_sub = $parms->{sort_files};
- while ( defined ( my $file = readdir $dh ) ) {
- next if $skip_dirs{$file};
+ for my $file ( grep { !exists $skip_dirs{$_} } readdir $dh ) {
my $has_stat;
# Only do directory checking if we have a descend_filter
@@ -1013,7 +1054,7 @@ use strict;
our $VERSION;
our $COPYRIGHT;
BEGIN {
- $VERSION = '1.88';
+ $VERSION = '1.90';
$COPYRIGHT = 'Copyright 2005-2009 Andy Lester, all rights reserved.';
}
@@ -1029,10 +1070,12 @@ our %type_wanted;
our %mappings;
our %ignore_dirs;
+our $input_from_pipe;
+our $output_to_pipe;
+
our $dir_sep_chars;
our $is_cygwin;
our $is_windows;
-our $to_screen;
use File::Spec ();
use File::Glob ':glob';
@@ -1063,6 +1106,7 @@ BEGIN {
%mappings = (
actionscript => [qw( as mxml )],
+ ada => [qw( ada adb ads )],
asm => [qw( asm s )],
batch => [qw( bat cmd )],
binary => q{Binary files, as defined by Perl's -B op (default: off)},
@@ -1094,7 +1138,7 @@ BEGIN {
python => [qw( py )],
rake => q{Rakefiles},
ruby => [qw( rb rhtml rjs rxml erb rake )],
- scheme => [qw( scm )],
+ scheme => [qw( scm ss )],
shell => [qw( sh bash csh tcsh ksh zsh )],
skipped => q{Files, but not directories, normally skipped by ack (default: off)},
smalltalk => [qw( st )],
@@ -1117,10 +1161,13 @@ BEGIN {
}
}
- $is_cygwin = ($^O eq 'cygwin');
- $is_windows = ($^O =~ /MSWin32/);
- $to_screen = -t *STDOUT;
- $dir_sep_chars = $is_windows ? quotemeta( '\\/' ) : quotemeta( File::Spec->catfile( '', '' ) );
+ # These have to be checked before any filehandle diddling.
+ $output_to_pipe = not -t *STDOUT;
+ $input_from_pipe = -p STDIN;
+
+ $is_cygwin = ($^O eq 'cygwin');
+ $is_windows = ($^O =~ /MSWin32/);
+ $dir_sep_chars = $is_windows ? quotemeta( '\\/' ) : quotemeta( File::Spec->catfile( '', '' ) );
}
@@ -1164,6 +1211,9 @@ sub get_command_line_options {
'break!' => \$opt{break},
c => \$opt{count},
'color|colour!' => \$opt{color},
+ 'color-match=s' => \$ENV{ACK_COLOR_MATCH},
+ 'color-filename=s' => \$ENV{ACK_COLOR_FILENAME},
+ 'column!' => \$opt{column},
count => \$opt{count},
'env!' => sub { }, # ignore this option, it is handled beforehand
f => \$opt{f},
@@ -1178,10 +1228,10 @@ sub get_command_line_options {
'i|ignore-case' => \$opt{i},
'lines=s' => sub { shift; my $val = shift; push @{$opt{lines}}, $val },
'l|files-with-matches' => \$opt{l},
- 'L|files-without-match' => sub { $opt{l} = $opt{v} = 1 },
+ 'L|files-without-matches' => sub { $opt{l} = $opt{v} = 1 },
'm|max-count=i' => \$opt{m},
'match=s' => \$opt{regex},
- n => \$opt{n},
+ 'n|no-recurse' => \$opt{n},
o => sub { $opt{output} = '$&' },
'output=s' => \$opt{output},
'pager=s' => \$opt{pager},
@@ -1189,6 +1239,7 @@ sub get_command_line_options {
'passthru' => \$opt{passthru},
'print0' => \$opt{print0},
'Q|literal' => \$opt{Q},
+ 'r|R|recurse' => sub {},
'smart-case!' => \$opt{smart_case},
'sort-files' => \$opt{sort_files},
'u|unrestricted' => \$opt{u},
@@ -1235,6 +1286,7 @@ sub get_command_line_options {
$parser->getoptions( %{$getopt_specs} ) or
App::Ack::die( 'See ack --help or ack --man for options.' );
+ my $to_screen = not output_to_pipe();
my %defaults = (
all => 0,
color => $to_screen,
@@ -1401,8 +1453,9 @@ sub filetypes {
my $basename = $filename;
$basename =~ s{.*[$dir_sep_chars]}{};
- return ('make',TEXT) if lc $basename eq 'makefile';
- return ('rake','ruby',TEXT) if lc $basename eq 'rakefile';
+ my $lc_basename = lc $basename;
+ return ('make',TEXT) if $lc_basename eq 'makefile';
+ return ('rake','ruby',TEXT) if $lc_basename eq 'rakefile';
# If there's an extension, look it up
if ( $filename =~ m{\.([^\.$dir_sep_chars]+)$}o ) {
@@ -1573,8 +1626,8 @@ Search output:
--line=NUM Only print line(s) NUM of each file
-l, --files-with-matches
Only print filenames containing matches
- -L, --files-without-match
- Only print filenames with no match
+ -L, --files-without-matches
+ Only print filenames with no matches
-o Show only the part of a line matching PATTERN
(turns off text highlighting)
--passthru Print all lines, whether matching or not
@@ -1586,6 +1639,7 @@ Search output:
-H, --with-filename Print the filename for each match
-h, --no-filename Suppress the prefixing filename on output
-c, --count Show number of lines matching per file
+ --column Show the column number of the first match
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching
@@ -1600,8 +1654,8 @@ Search output:
only works with -f, -g, -l, -L or -c.
File presentation:
- --pager=COMMAND Pipes all ack output through COMMAND.
- Ignored if output is redirected.
+ --pager=COMMAND Pipes all ack output through COMMAND. For example,
+ --pager="less -R". Ignored if output is redirected.
--nopager Do not send output through a pager. Cancels any
setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR.
--[no]heading Print a filename heading above each file's results.
@@ -1613,6 +1667,8 @@ File presentation:
--[no]color Highlight the matching text (default: on unless
output is redirected, or on Windows)
--[no]colour Same as --[no]color
+ --color-filename=COLOR
+ --color-match=COLOR Set the color for matches and filenames.
--flush Flush output immediately, even when ack is used
non-interactively (when output goes to a pipe or
file).
@@ -1628,7 +1684,8 @@ File inclusion/exclusion:
Ignores CVS, .svn and other ignored directories
-u, --unrestricted All files and directories searched
--[no]ignore-dir=name Add/Remove directory from the list of ignored dirs
- -n No descending into subdirectories
+ -r, -R, --recurse Recurse into subdirectories (ack's default behavior)
+ -n, --no-recurse No descending into subdirectories
-G REGEX Only search files that match REGEX
--perl Include only Perl files.
@@ -1720,14 +1777,25 @@ sub _listify {
sub get_version_statement {
+ require Config;
+
my $copyright = get_copyright();
+ my $this_perl = $Config::Config{perlpath};
+ if ($^O ne 'VMS') {
+ my $ext = $Config::Config{_exe};
+ $this_perl .= $ext unless $this_perl =~ m/$ext$/i;
+ }
+ my $ver = sprintf( '%vd', $^V );
+
return <<"END_OF_VERSION";
ack $VERSION
+Running under Perl $ver at $this_perl
$copyright
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
+This program is free software; you can redistribute it and/or modify
+it under the terms of either: the GNU General Public License as
+published by the Free Software Foundation; or the Artistic License.
END_OF_VERSION
}
@@ -1784,6 +1852,7 @@ sub print_blank_line { App::Ack::print( "\n" ) }
sub print_separator { App::Ack::print( "--\n" ) }
sub print_filename { App::Ack::print( $_[0], $_[1] ) }
sub print_line_no { App::Ack::print( $_[0], $_[1] ) }
+sub print_column_no { App::Ack::print( $_[0], $_[1] ) }
sub print_count {
my $filename = shift;
my $nmatches = shift;
@@ -1865,7 +1934,7 @@ sub search_resource {
if ( $keep_context ) {
if ( $after ) {
- print_match_or_context( $opt, 0, $., $_ );
+ print_match_or_context( $opt, 0, $., $-[0], $+[0], $_ );
$after--;
}
elsif ( $before_context ) {
@@ -1900,7 +1969,7 @@ sub search_resource {
}
if ( $keep_context ) {
if ( @before ) {
- print_match_or_context( $opt, 0, $before_starts_at_line, @before );
+ print_match_or_context( $opt, 0, $before_starts_at_line, $-[0], $+[0], @before );
@before = ();
$before_starts_at_line = 0;
}
@@ -1911,7 +1980,7 @@ sub search_resource {
$after = $after_context;
}
}
- print_match_or_context( $opt, 1, $., $_ );
+ print_match_or_context( $opt, 1, $., $-[0], $+[0], $_ );
last if $max && ( $nmatches >= $max ) && !$after;
} # while
@@ -1922,13 +1991,16 @@ sub search_resource {
sub print_match_or_context {
- my $opt = shift; # opts array
- my $is_match = shift; # is there a match on the line?
- my $line_no = shift;
-
- my $color = $opt->{color};
- my $heading = $opt->{heading};
+ my $opt = shift; # opts array
+ my $is_match = shift; # is there a match on the line?
+ my $line_no = shift;
+ my $match_start = shift;
+ my $match_end = shift;
+
+ my $color = $opt->{color};
+ my $heading = $opt->{heading};
my $show_filename = $opt->{show_filename};
+ my $show_column = $opt->{column};
if ( $show_filename ) {
if ( not defined $display_filename ) {
@@ -1975,6 +2047,9 @@ sub print_match_or_context {
# remove any kind of newline at the end of the line
s/[\r\n]*\z//;
}
+ if ( $show_column ) {
+ App::Ack::print_column_no( $match_start+1, $sep );
+ }
App::Ack::print($_ . "\n");
}
$any_output = 1;
@@ -2081,7 +2156,8 @@ sub print_matches {
my $nmatches = 0;
while ( defined ( my $filename = $iter->() ) ) {
my $repo;
- if ( $filename =~ /\.tar\.gz$/ ) {
+ my $tarballs_work = 0;
+ if ( $tarballs_work && $filename =~ /\.tar\.gz$/ ) {
App::Ack::die( 'Not working here yet' );
require App::Ack::Repository::Tar; # XXX Error checking
$repo = App::Ack::Repository::Tar->new( $filename );
@@ -2238,7 +2314,7 @@ sub get_iterator {
sub set_up_pager {
my $command = shift;
- return unless $to_screen;
+ return unless App::Ack::output_to_pipe();
my $pager;
if ( not open( $pager, '|-', $command ) ) {
@@ -2250,6 +2326,18 @@ sub set_up_pager {
}
+sub input_from_pipe {
+ return $input_from_pipe;
+}
+
+
+
+sub output_to_pipe {
+ return $output_to_pipe;
+}
+
+
+
1; # End of App::Ack
package App::Ack::Repository;
View
62 ack-base
@@ -3,8 +3,8 @@
use warnings;
use strict;
-our $VERSION = '1.88';
-# Check http://petdance.com/ack/ for updates
+our $VERSION = '1.90';
+# Check http://betterthangrep.com/ for updates
# These are all our globals.
@@ -50,7 +50,7 @@ sub main {
$| = 1 if $opt->{flush}; # Unbuffer the output if flush mode
- if ( -p STDIN ) { # Check to see if it's a pipe
+ if ( App::Ack::input_from_pipe() ) {
# We're going into filter mode
for ( qw( f g l ) ) {
$opt->{$_} and App::Ack::die( "Can't use -$_ when acting as a filter." );
@@ -205,6 +205,19 @@ On Windows, this option is off by default unless the
L<Win32::Console::ANSI> module is installed or the C<ACK_PAGER_COLOR>
environment variable is used.
+=item B<--color-filename=I<color>>
+
+Sets the color to be used for filenames.
+
+=item B<--color-match=I<color>>
+
+Sets the color to be used for matches.
+
+=item B<--column>
+
+Show the column number of the first match. This is helpful for editors
+that can place your cursor at a given position.
+
=item B<--env>, B<--noenv>
B<--noenv> disables all environment processing. No F<.ackrc> is read
@@ -565,11 +578,15 @@ Underline and underscore are equivalent, as are clear and reset.
The color alone sets the foreground color, and on_color sets the
background color.
+This option can also be set with B<--color-filename>.
+
=item ACK_COLOR_MATCH
Specifies the color of the matching text when printed in B<--color>
mode. By default, it's "black on_yellow".
+This option can also be set with B<--color-match>.
+
See B<ACK_COLOR_FILENAME> for the color specifications.
=item ACK_PAGER
@@ -672,7 +689,11 @@ list of all the Perl files in a tree, ideal for sending into F<xargs>.
For example:
# Change all "this" to "that" in all Perl files in a tree.
- ack -f --perl | perl -p -i -e's/this/that/g'
+ ack -f --perl | xargs perl -p -i -e's/this/that/g'
+
+or if you prefer:
+
+ perl -p -i -e's/this/thatg/' $(ack -f --perl)
=head2 Use F<-Q> when in doubt about metacharacters
@@ -698,6 +719,20 @@ the previous five lines from the log in each case.
Join the ack-users mailing list. Send me your tips and I may add
them here.
+=head1 FAQ
+
+=head2 Wouldn't it be great if F<ack> did search & replace?
+
+No, ack will always be read-only. Perl has a perfectly good way
+to do search & replace in files, using the C<-i>, C<-p> and C<-n>
+switches.
+
+You can certainly use ack to select your files to update. For
+example, to change all "foo" to "bar" in all PHP files, you can do
+this form the Unix shell:
+
+ $ perl -i -p -e's/foo/bar/g' $(ack -f --php)
+
=head1 AUTHOR
Andy Lester, C<< <andy at petdance.com> >>
@@ -728,7 +763,7 @@ Support for and information about F<ack> can be found at:
=item * The ack homepage
-L<http://petdance.com/ack/>
+L<http://betterthangrep.com/>
=item * The ack issues list at Google Code
@@ -757,6 +792,11 @@ L<http://ack.googlecode.com/svn/>
How appropriate to have I<ack>nowledgements!
Thanks to everyone who has contributed to ack in any way, including
+Ryan Niebur,
+Kent Fredric,
+Mike Morearty,
+Ingmar Vanhassel,
+Eric Van Dewoestine,
Sitaram Chamarty,
Adam James,
Richard Carlsson,
@@ -777,10 +817,10 @@ Kevin Riggle,
Ori Avtalion,
Torsten Blix,
Nigel Metheringham,
-Gábor Szabó,
+GE<aacute>bor SzabE<oacute>,
Tod Hagan,
Michael Hendricks,
-Ævar Arnfjörð Bjarmason,
+E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason,
Piers Cawley,
Stephen Steneker,
Elias Lutfallah,
@@ -795,11 +835,11 @@ Elliot Shank,
Merijn Broeren,
Uwe Voelker,
Rick Scott,
-Ask Bjørn Hansen,
+Ask BjE<oslash>rn Hansen,
Jerry Gay,
Will Coleda,
Mike O'Regan,
-Slaven Rezić,
+Slaven ReziE<0x107>,
Mark Stosberg,
David Alan Pisoni,
Adriano Ferreira,
@@ -810,7 +850,7 @@ and Pete Krawczyk.
=head1 COPYRIGHT & LICENSE
-Copyright 2005-2009 Andy Lester, all rights reserved.
+Copyright 2005-2009 Andy Lester.
This program is free software; you can redistribute it and/or modify
it under the terms of either:
@@ -821,7 +861,7 @@ it under the terms of either:
Software Foundation; either version 1, or (at your option) any later
version, or
-=item * the "Artistic License" which comes with Perl 5.
+=item * the Artistic License version 2.0.
=back
View
3  ack-help-types.txt
@@ -8,6 +8,7 @@ Note that some extensions may appear in multiple types. For example,
.pod files are both Perl and Parrot.
--[no]actionscript .as .mxml
+ --[no]ada .ada .adb .ads
--[no]asm .asm .s
--[no]batch .bat .cmd
--[no]binary Binary files, as defined by Perl's -B op (default: off)
@@ -39,7 +40,7 @@ Note that some extensions may appear in multiple types. For example,
--[no]python .py
--[no]rake Rakefiles
--[no]ruby .rb .rhtml .rjs .rxml .erb .rake
- --[no]scheme .scm
+ --[no]scheme .scm .ss
--[no]shell .sh .bash .csh .tcsh .ksh .zsh
--[no]skipped Files, but not directories, normally skipped by ack (default: off)
--[no]smalltalk .st
View
16 ack-help.txt
@@ -24,8 +24,8 @@ Search output:
--line=NUM Only print line(s) NUM of each file
-l, --files-with-matches
Only print filenames containing matches
- -L, --files-without-match
- Only print filenames with no match
+ -L, --files-without-matches
+ Only print filenames with no matches
-o Show only the part of a line matching PATTERN
(turns off text highlighting)
--passthru Print all lines, whether matching or not
@@ -37,6 +37,7 @@ Search output:
-H, --with-filename Print the filename for each match
-h, --no-filename Suppress the prefixing filename on output
-c, --count Show number of lines matching per file
+ --column Show the column number of the first match
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching
@@ -51,8 +52,8 @@ Search output:
only works with -f, -g, -l, -L or -c.
File presentation:
- --pager=COMMAND Pipes all ack output through COMMAND.
- Ignored if output is redirected.
+ --pager=COMMAND Pipes all ack output through COMMAND. For example,
+ --pager="less -R". Ignored if output is redirected.
--nopager Do not send output through a pager. Cancels any
setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR.
--[no]heading Print a filename heading above each file's results.
@@ -64,6 +65,8 @@ File presentation:
--[no]color Highlight the matching text (default: on unless
output is redirected, or on Windows)
--[no]colour Same as --[no]color
+ --color-filename=COLOR
+ --color-match=COLOR Set the color for matches and filenames.
--flush Flush output immediately, even when ack is used
non-interactively (when output goes to a pipe or
file).
@@ -79,7 +82,8 @@ File inclusion/exclusion:
Ignores CVS, .svn and other ignored directories
-u, --unrestricted All files and directories searched
--[no]ignore-dir=name Add/Remove directory from the list of ignored dirs
- -n No descending into subdirectories
+ -r, -R, --recurse Recurse into subdirectories (ack's default behavior)
+ -n, --no-recurse No descending into subdirectories
-G REGEX Only search files that match REGEX
--perl Include only Perl files.
@@ -117,4 +121,4 @@ Miscellaneous:
Exit status is 0 if match, 1 if no match.
-This is version 1.88 of ack.
+This is version 1.90 of ack.
View
54 btg/ack-help-types.txt
@@ -0,0 +1,54 @@
+Usage: ack [OPTION]... PATTERN [FILES]
+
+The following is the list of filetypes supported by ack. You can
+specify a file type with the --type=TYPE format, or the --TYPE
+format. For example, both --type=perl and --perl work.
+
+Note that some extensions may appear in multiple types. For example,
+.pod files are both Perl and Parrot.
+
+ --[no]actionscript .as .mxml
+ --[no]asm .asm .s
+ --[no]batch .bat .cmd
+ --[no]binary Binary files, as defined by Perl's -B op (default: off)
+ --[no]cc .c .h .xs
+ --[no]cfmx .cfc .cfm .cfml
+ --[no]cpp .cpp .cc .cxx .m .hpp .hh .h .hxx
+ --[no]csharp .cs
+ --[no]css .css
+ --[no]elisp .el
+ --[no]erlang .erl .hrl
+ --[no]fortran .f .f77 .f90 .f95 .f03 .for .ftn .fpp
+ --[no]haskell .hs .lhs
+ --[no]hh .h
+ --[no]html .htm .html .shtml .xhtml
+ --[no]java .java .properties
+ --[no]js .js
+ --[no]jsp .jsp .jspx .jhtm .jhtml
+ --[no]lisp .lisp .lsp
+ --[no]lua .lua
+ --[no]make Makefiles
+ --[no]mason .mas .mhtml .mpl .mtxt
+ --[no]objc .m .h
+ --[no]objcpp .mm .h
+ --[no]ocaml .ml .mli
+ --[no]parrot .pir .pasm .pmc .ops .pod .pg .tg
+ --[no]perl .pl .pm .pod .t
+ --[no]php .php .phpt .php3 .php4 .php5
+ --[no]plone .pt .cpt .metadata .cpy .py
+ --[no]python .py
+ --[no]rake Rakefiles
+ --[no]ruby .rb .rhtml .rjs .rxml .erb .rake
+ --[no]scheme .scm
+ --[no]shell .sh .bash .csh .tcsh .ksh .zsh
+ --[no]skipped Files, but not directories, normally skipped by ack (default: off)
+ --[no]smalltalk .st
+ --[no]sql .sql .ctl
+ --[no]tcl .tcl .itcl .itk
+ --[no]tex .tex .cls .sty
+ --[no]text Text files, as defined by Perl's -T op (default: off)
+ --[no]tt .tt .tt2 .ttml
+ --[no]vb .bas .cls .frm .ctl .vb .resx
+ --[no]vim .vim
+ --[no]xml .xml .dtd .xslt .ent
+ --[no]yaml .yaml .yml
View
120 btg/ack-help.txt
@@ -0,0 +1,120 @@
+Usage: ack [OPTION]... PATTERN [FILE]
+
+Search for PATTERN in each source file in the tree from cwd on down.
+If [FILES] is specified, then only those files/directories are checked.
+ack may also search STDIN, but only if no FILE are specified, or if
+one of FILES is "-".
+
+Default switches may be specified in ACK_OPTIONS environment variable or
+an .ackrc file. If you want no dependency on the environment, turn it
+off with --noenv.
+
+Example: ack -i select
+
+Searching:
+ -i, --ignore-case Ignore case distinctions in PATTERN
+ --[no]smart-case Ignore case distinctions in PATTERN,
+ only if PATTERN contains no upper case
+ Ignored if -i is specified
+ -v, --invert-match Invert match: select non-matching lines
+ -w, --word-regexp Force PATTERN to match only whole words
+ -Q, --literal Quote all metacharacters; PATTERN is literal
+
+Search output:
+ --line=NUM Only print line(s) NUM of each file
+ -l, --files-with-matches
+ Only print filenames containing matches
+ -L, --files-without-match
+ Only print filenames with no match
+ -o Show only the part of a line matching PATTERN
+ (turns off text highlighting)
+ --passthru Print all lines, whether matching or not
+ --output=expr Output the evaluation of expr for each line
+ (turns off text highlighting)
+ --match PATTERN Specify PATTERN explicitly.
+ -m, --max-count=NUM Stop searching in each file after NUM matches
+ -1 Stop searching after one match of any kind
+ -H, --with-filename Print the filename for each match
+ -h, --no-filename Suppress the prefixing filename on output
+ -c, --count Show number of lines matching per file
+
+ -A NUM, --after-context=NUM
+ Print NUM lines of trailing context after matching
+ lines.
+ -B NUM, --before-context=NUM
+ Print NUM lines of leading context before matching
+ lines.
+ -C [NUM], --context[=NUM]
+ Print NUM lines (default 2) of output context.
+
+ --print0 Print null byte as separator between filenames,
+ only works with -f, -g, -l, -L or -c.
+
+File presentation:
+ --pager=COMMAND Pipes all ack output through COMMAND.
+ Ignored if output is redirected.
+ --nopager Do not send output through a pager. Cancels any
+ setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR.
+ --[no]heading Print a filename heading above each file's results.
+ (default: on when used interactively)
+ --[no]break Print a break between results from different files.
+ (default: on when used interactively)
+ --group Same as --heading --break
+ --nogroup Same as --noheading --nobreak
+ --[no]color Highlight the matching text (default: on unless
+ output is redirected, or on Windows)
+ --[no]colour Same as --[no]color
+ --flush Flush output immediately, even when ack is used
+ non-interactively (when output goes to a pipe or
+ file).
+
+File finding:
+ -f Only print the files found, without searching.
+ The PATTERN must not be specified.
+ -g REGEX Same as -f, but only print files matching REGEX.
+ --sort-files Sort the found files lexically.
+
+File inclusion/exclusion:
+ -a, --all-types All file types searched;
+ Ignores CVS, .svn and other ignored directories
+ -u, --unrestricted All files and directories searched
+ --[no]ignore-dir=name Add/Remove directory from the list of ignored dirs
+ -n No descending into subdirectories
+ -G REGEX Only search files that match REGEX
+
+ --perl Include only Perl files.
+ --type=perl Include only Perl files.
+ --noperl Exclude Perl files.
+ --type=noperl Exclude Perl files.
+ See "ack --help type" for supported filetypes.
+
+ --type-set TYPE=.EXTENSION[,.EXT2[,...]]
+ Files with the given EXTENSION(s) are recognized as
+ being of type TYPE. This replaces an existing
+ definition for type TYPE.
+ --type-add TYPE=.EXTENSION[,.EXT2[,...]]
+ Files with the given EXTENSION(s) are recognized as
+ being of (the existing) type TYPE
+
+ --[no]follow Follow symlinks. Default is off.
+
+ Directories ignored by default:
+ autom4te.cache, blib, _build, .bzr, .cdv, cover_db, CVS, _darcs, ~.dep,
+ ~.dot, .git, .hg, ~.nib, .pc, ~.plst, RCS, SCCS, _sgbak and .svn
+
+ Files not checked for type:
+ /~$/ - Unix backup files
+ /#.+#$/ - Emacs swap files
+ /[._].*\.swp$/ - Vi(m) swap files
+ /core\.\d+$/ - core dumps
+
+Miscellaneous:
+ --noenv Ignore environment variables and ~/.ackrc
+ --help This help
+ --man Man page
+ --version Display version & copyright
+ --thpppt Bill the Cat
+
+Exit status is 0 if match, 1 if no match.
+
+This is version 1.88 of ack.
View
77 btg/ack-lists.php
@@ -0,0 +1,77 @@
+<table style="border:1px solid #aa0033; font-size:small" align=right>
+ <tr>
+ <td colspan=2 align=center>
+ <img src="http://groups.google.com/groups/img/groups_medium.gif" height=58 width=150 alt="Google Groups">
+ </td>
+</tr>
+
+<tr>
+ <td colspan=2 align=center><b>Subscribe to ack announcements</b></td>
+ </tr>
+ <form action="http://groups.google.com/group/ack-announce/boxsubscribe">
+ <tr>
+ <td>Email: <input type=text name=email></td>
+ <td>
+ <table
+ style="background-color:#ffcc33;padding:2px;border:2px outset #ffcc33;">
+ <tr>
+ <td>
+ <input type=submit name="sub" value="Subscribe">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </form>
+ <tr><td colspan=2 align=center>
+ <a href="http://groups.google.com/group/ack-announce">Browse Archives</a> at <a href="http://groups.google.com/">groups.google.com</a>
+ </td></tr>
+ <tr><td colspan=2><hr></td></tr>
+
+
+<tr>
+ <td colspan=2 align=center><b>Subscribe to ack dev/users</b></td>
+ </tr>
+ <form action="http://groups.google.com/group/ack-users/boxsubscribe">
+ <tr>
+ <td>Email: <input type=text name=email></td>
+ <td>
+ <table
+ style="background-color:#ffcc33;padding:2px;border:2px outset #ffcc33;">
+ <tr>
+ <td>
+ <input type=submit name="sub" value="Subscribe">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </form>
+ <tr><td colspan=2 align=center>
+ <a href="http://groups.google.com/group/ack-users">Browse Archives</a> at <a href="http://groups.google.com/">groups.google.com</a>
+ </td></tr>
+ <tr><td colspan=2><hr></td></tr>
+
+
+ <tr>
+ <td colspan=2 align=center><b>Subscribe to ack commits</b></td>
+ </tr>
+ <form action="http://groups.google.com/group/ack-commits/boxsubscribe">
+ <tr>
+ <td>Email: <input type=text name=email></td>
+ <td>
+ <table
+ style="background-color:#ffcc33;padding:2px;border:2px outset #ffcc33;">
+ <tr>
+ <td>
+ <input type=submit name="sub" value="Subscribe">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </form>
+ <tr><td colspan=2 align=center>
+ <a href="http://groups.google.com/group/ack-commits">Browse Archives</a> at <a href="http://groups.google.com/">groups.google.com</a>
+ </td></tr>
+</table>
View
247 btg/index.php
@@ -0,0 +1,247 @@
+<html>
+ <head>
+ <meta NAME="Author" Content="Andy Lester">
+ <title>ack -- better than grep, a power search tool for programmers</title>
+ <style type="text/css">
+ <!--
+ div.bill pre {
+ font-weight : bold;
+ font-size : 25pt;
+ }
+ body {
+ margin-left: 100px;
+ margin-right: 100px;
+ }
+ -->
+ </style>
+ </head>
+ <body bgcolor="white">
+ <div class="bill" align="center">
+ <table border="0" cellpadding="10" cellspacing="20">
+ <tr>
+ <td>
+<pre>
+_ /|
+\'o.O'
+=(___)=
+ U ack!
+</pre>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <?php include "ack-lists.php" ?>
+
+ <h2>Latest version of ack: 1.88, February 6th, 2009</h2>
+ Read the <a href="http://ack.googlecode.com/svn/tags/latest/Changes">Changelog</a>
+
+ <p>
+ <b>ack</b> is a tool like grep, aimed at programmers with large trees of
+ heterogeneous source code.
+ <p>
+ ack is written purely in Perl, and takes advantage of the power of Perl's
+ regular expressions.
+ </p>
+
+ <h2>How to install ack</h2>
+
+ <p>
+ It can be installed any number of ways:
+ </p>
+ <ul>
+ <li>
+ <b>Install the CPAN module <a href="http://search.cpan.org/dist/ack">App::Ack</a></b>.
+ If you are a Perl user already, this is the way to go.
+ </li>
+ <li>
+ <b>Download the
+ <a href="http://ack.googlecode.com/svn/tags/latest/ack">standalone version</a></b> of ack
+ that requires no modules beyond what's in core Perl, and putting it in your path.
+ If you don't want to mess with setting up Perl's CPAN shell, this is easiest.
+ <blockquote>
+ <code>
+ curl http://ack.googlecode.com/svn/tags/latest/ack &gt; ~/bin/ack &amp;&amp; chmod 0755 !$
+ </code>
+ </blockquote>
+ </li>
+ <li>Install the <b>Macport</b>: <a href="http://trac.macports.org/browser/trunk/dports/perl/p5-app-ack/Portfile">http://trac.macports.org/browser/trunk/dports/perl/p5-app-ack/Portfile</a></li>
+ <li>Install the <b>Ubuntu package</b>: ack-grep</li>
+ <li>Install the <b>Fedora package</b>: ack</li>
+ <li>Install the <b>Gentoo package</b>: sys-apps/ack</li>
+ </ul>
+
+ <h2>Ack in Project for Textmate users</h2>
+ <p>
+ Users of TextMate, the programmer's editor for the Mac, can use the Ack in Project plugin by Trevor Squires:
+ </p>
+ <blockquote>
+ TextMate users know just how slow its “Find in Project”
+ can be with large source trees. That’s why you need
+ "ack-in-project" – a TextMate bundle that uses
+ the super-speedy ‘ack’ tool to search your code
+ FAST. It gives you beautiful, clickable results just
+ as fast as "ack" can find them. Check it out at:
+ <a href="http://github.com/protocool/ack-tmbundle/tree/master">http://github.com/protocool/ack-tmbundle/tree/master</a>
+ </blockquote>
+
+ <h2>Testimonials</h2>
+
+ <p>
+ "Whoa, this is *so* much better than grep it's not even funny."
+ -- <a href="http://jacobian.org/">Jacob Kaplan-Moss</a>, creator of <a href="http://www.djangoproject.com/">Django</a>.
+ </p>
+
+
+ <p>
+ "Thanks for creating ack and sharing it with the world. It
+ makes my days just a little more pleasant. I'm glad to have it
+ in my toolbox. That installation is as simple as downloading the
+ standalone version and chmodding is a nice touch."
+ -- <a href="http://www.highprogrammer.com/alan/">Alan De Smet</a>
+ </p>
+
+ <p>
+ "I came across ack today, and now grep is sleeping outside. It's very
+ much like grep, except it assumes all the little things that you always
+ wanted grep to remember, but that it never did. It actually left the
+ light on for you, and put the toilet seat down."
+ -- <a href="http://assistedsilicon.blogspot.com/2008/09/ack-grep-but-better.html">Samuel Huckins</a>
+ </p>
+
+ <p>
+ "ack is the best tool I have added to my toolbox in the past year, hands down."
+ -- <a href="http://billmill.org/">Bill Mill</a> on <a href="http://www.reddit.com/info/6odl4/comments/">reddit</a>
+ </p>
+
+ <p>
+ "I use it all the time and I can't imagine how I managed with only
+ grep."
+ -- <a href="http://marnanel.org/">Thomas Thurman</a>
+ </p>
+
+ <p>
+ "This has been replacing a Rube Goldberg mess of <tt>find/grep/xargs</tt>
+ that I've been using to search source files in a fairly large codebase."
+ -- <a href="http://www.anomaly.org/wade/">G. Wade Johnson</a>
+ </p>
+
+ <p>
+ "You had me at <tt>--thpppt</tt>."
+ -- John Gruber, <a href="http://daringfireball.net/linked/2007/november#tue-27-ack">Daring Fireball</a>
+
+ </p>
+ <p>
+ "Grepping of SVN repositories was driving me crazy until I found ack. It
+ fixes all of my grep annoyances and adds features I didn't even know I
+ wanted." -- <a href="http://www.prescod.net/">Paul Prescod</a>
+
+ <p>
+ "I added ack standalone to our internal devtools project at work. People
+ are all over it." -- <a href="http://www.multiply.org/">Jason Gessner</a>
+
+ <p>
+ "I just wanted to send you my praise for this wonderful little
+ application. It's in my toolbox now and after one day of use has proven
+ itself invaluable." -- <a href="http://www.just-another.net/">Benjamin W. Smith</a>
+
+ <p>
+ "ack has replaced grep for me for 90% of what I used it for.
+ Obsoleted most of my 'grep is crippled' wrapper scripts, too."
+ -- Randall Hansen
+
+ <p>
+ "ack's powerful search facilities are an invaluable tool for searching
+ large repositories like <a href="http://parrot.org/">Parrot</a>. The
+ ability to control the search domain by filetype--and to do so
+ independent of platform--has made one-liners out of many complex
+ queries previously done with custom scripts. Parrot developers
+ are hooked on ack."
+ -- <a href="http://www.rakudoconsulting.com/">Jerry Gay</a>
+ </p>
+
+ <p>
+ "That thing is awesome. People see me using it and ask what the heck it is."
+ -- Andrew Moore
+ </p>
+
+ <h2>Top 10 reasons to use ack instead of grep.</h2>
+ <ol>
+ <li>It's <b>blazingly fast</b> because it only searches the stuff you want searched.</li>
+ <li>ack is pure Perl, so it <b>runs on Windows</b> just fine.</li>
+ <li>The <a href="http://ack.googlecode.com/svn/tags/latest/ack">standalone
+ version</a> uses no non-standard modules, so you can put it in your
+ <tt>~/bin</tt> without fear.</li>
+ <li>
+ Searches recursively through directories by default, while ignoring
+ <tt>.svn</tt>, <tt>CVS</tt> and other VCS directories.
+ <ul>
+ <li>
+ Which would you rather type?<br>
+ <tt>$ grep pattern $(find . -type f | grep -v '\.svn')</tt><br>
+ <tt>$ ack pattern</tt>
+ </li>
+ </ul>
+ </li>
+ <li>ack <b>ignores most of the crap you don't want to search</b>
+ <ul>
+ <li>VCS directories
+ <li><i>blib</i>, the Perl build directory
+ <li>backup files like <i>foo~</i> and <i>#foo#</i>
+ <li>binary files, core dumps, etc
+ </ul>
+ </li>
+ <li>Ignoring .svn directories means that <b>ack is faster than grep</b> for searching through trees.</li>
+ <li><b>Lets you specify file types to search</b>, as in <tt>--perl</tt> or <tt>--nohtml</tt>.
+ <ul>
+ <li>Which would you rather type?<br>
+ <tt>$ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn)</tt><br>
+ <tt>$ ack --perl pattern</tt>
+ </li>
+ </ul>
+ Note that ack's <tt>--perl</tt> also checks the shebang lines of
+ files without suffixes, which the find command will not.
+ <li>File-filtering capabilities usable without searching with <tt>ack -f</tt>. This lets you <b>create lists of files of a given type</b>.<br>
+ <tt>$ ack -f --perl &gt; all-perl-files</tt>
+ <li><b>Color highlighting</b> of search results.
+ <li>Uses <b>real Perl regular expressions</b>, not a GNU subset.
+ <li>Allows you to specify output using Perl's special variables
+ <ul>
+ <li>Example: <tt>ack '(Mr|Mr?s)\. (Smith|Jones)' --output='$&amp;'</tt>
+ </ul>
+ <li>
+ Many command-line switches are the same as in GNU grep:<br>
+ <tt>-w</tt> does word-only searching<br>
+ <tt>-c</tt> shows counts per file of matches<br>
+ <tt>-l</tt> gives the filename instead of matching lines<br>
+ etc.
+ </li>
+ <li><b>Command name is 25% fewer characters to type!</b> Save days of free-time! Heck, it's 50% shorter compared to <tt>grep -r</tt>.</li>
+ </ol>
+ <hr>
+ <h2>Ack's command flags</h2>
+
+<pre>
+$ ack --help
+<?php include "ack-help.txt" ?>
+</pre>
+ <hr>
+ <h2>File types that ack understands</h2>
+<pre>
+$ ack --help-types
+<?php include "ack-help-types.txt" ?>
+</pre>
+
+
+ <!-- Google tracking, must be just before close of body tag -->
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+var pageTracker = _gat._getTracker("UA-631706-7");
+pageTracker._initData();
+pageTracker._trackPageview();
+</script>
+ </body>
+</html>
View
12 capture-stderr
@@ -2,12 +2,18 @@
use strict;
# Untaint our arguments (we're very trusting):
-my ($stderr) = ((shift @ARGV) =~ /^(.+)$/s) or die 'No stderr';
-my ($program) = ((shift @ARGV) =~ /^(.+)$/s) or die 'No program';
+my $stderr = shift or die 'No stderr';
+my $program = shift or die 'No program';
+
+for ( $stderr, $program ) {
+ /^(.+)$/ or die;
+ $_ = $1;
+}
open(STDERR, '>', $stderr) or die "Can't redirect STDERR to $stderr: $!";
$0 = $program;
-do $program;
+my $rc = do $program;
+die "$program fails with return code $rc" if $rc;
die $@ if $@;
die "Couldn't run $program: $!"; # Ack doesn't return, it calls exit
View
137 etc/ack.bash_completion.sh
@@ -1,44 +1,107 @@
-# vim: et ft=sh ts=2 sts=2 sw=2
-# By Adam James: atj@pulsewidth.org.uk
+# vim: et ft=sh sts=2 sw=2 ts=2
+#
+# Copyright 2008-2009 Adam James <atj@pulsewidth.org.uk>
+# All rights reserved.
+# This program is free software; you can redistribute it and/or modify it
+# under the same terms as ack itself.
+
+# ack-grep on Debian distros
+type ack &>/dev/null || type ack-grep &>/dev/null && {
+
+shopt -s extglob
+
+__ack_filedir()
+{
+ local IFS=$'\n\t' flag="-f" tmp
+
+ [[ $1 == "-d" ]] && flag="-d"
+
+ COMPREPLY=( $(compgen ${flag} -- "${cur}" | {
+ while read -r tmp; do
+ if [[ -d ${tmp} ]]; then
+ echo "${tmp// /\\ }/"
+ else
+ echo "${tmp// /\\ }"
+ fi
+ done
+ } ) )
+}
_ack()
{
- local cur prev long_options short_options type_options
COMPREPLY=()
+ # --help, --man, --thpppt and --version are final
+ # so we return here if they are present
+ [[ "${COMP_WORDS[@]}" == \
+ *+([[:space:]])--@(help|man|th+(p)t|version)+([[:space:]])* ]] && return 0
+
+ local cur lngopt shtopt fnlopt typeopt
cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
-
- long_options="--all --after-context= --before-context= --content= --count \
- --color --nocolor --env --noenv --follow --nofollow --group --nogroup \
- --with-filename --no-filename --help --ignore-case --ignore-dir= \
- --noignore-dir= --line= --files-with-matches --match --max-count= \
- --man --output= --pager= --passthru --literal --rc= --sort-files \
- --thpppt --unrestricted --invert-match --version --word-regexp"
- short_options="-a -A -B -C -c -f -G -g -H -h -i -l -m= -n -o -Q -u -w -1"
- if type ack &>/dev/null; then
- type_options=$(ack --help=types 2>/dev/null |perl -ne \
- 'print "--$1\n--no-$1\n" if /^\s+--\[no\](\S+)\s+/')
- fi
-
- if [[ "${cur}" == *=* ]]; then
- prev=${cur/=*/}
- cur=${cur/*=/}
- case "${prev}" in
- --ignore-dir) _filedir -d
- return 0
- ;;
- --rc) _filedir
- return 0
- ;;
- esac
- elif [[ "${cur}" == -* ]]; then
- COMPREPLY=( $(compgen -W \
- "${type_options} ${long_options} ${short_options}" -- "${cur}") )
- elif [[ "${prev}" != -* || " ${COMP_WORDS[@]} " == *" -f "* ]]; then
- _filedir
- fi
-
- return 0
-}
+ lngopt='
+ --all-types --after-context= --before-context= --context=
+ --count --color --nocolor --env --noenv --flush
+ --follow --nofollow --group --nogroup --with-filename
+ --no-filename --ignore-case --ignore-dir=
+ --noignore-dir= --line= --files-with-matches
+ --files-without-matches --match --max-count=
+ --output= --pager= --nopager --passthru --print0
+ --literal --smart-case --nosmart-case --rc=
+ --sort-files --type --type-add --type-set
+ --unrestricted --invert-match --word-regexp
+ --heading --noheading --break --nobreak --sort-files
+ '
+ shtopt='
+ -a -A -B -C -c
+ -f -G -g -H -h
+ -i -l -L -m -n
+ -o -Q -u -w -1
+ '
+ fnlopt='--help --man --thpppt --version'
+
+ # try ack-grep first as Debian distributions contain a completely
+ # different program called ack.
+ typeopt=$(ack-grep --help=types 2>/dev/null || \
+ ack --help=types 2>/dev/null |perl -ne \
+ 'print "--$1 --no$1 " if /^\s+--\[no\](\S+)\s+/' 2>/dev/null)
+
+ case "${cur}" in
+ # option with argument
+ -*=*)
+ # split the option and the argument
+ opt=${cur%%=*}
+ cur=${cur#*=}
+
+ # special cases
+ case "${opt}" in
+ --?(no)ignore-dir) # directory matching
+ #COMPREPLY=( $(compgen -d -- "${cur}") )
+ __ack_filedir -d
+ return 0;;
+ --rc) # file matching
+ #COMPREPLY=( $(compgen -f -- "${cur}") )
+ __ack_filedir
+ return 0;;
+ --pager) # command matching
+ COMPREPLY=( $(compgen -c -- "${cur}") )
+ return 0;;
+ *)
+ return 0;;
+ esac;;
+ # option without argument
+ -*)
+ [[ "${COMP_CWORD}" == 1 ]] && lngopt="${lngopt} ${fnlopt}"
+
+ COMPREPLY=( $(compgen -W \
+ "${lngopt} ${shtopt} ${typeopt}" -- "${cur}") )
+ return 0;;
+ *)
+ [[ "${COMP_WORDS[COMP_CWORD-1]}" != -* || \
+ " ${COMP_WORDS[@]} " == *" -f "* ]] && \
+ __ack_filedir
+ return 0;;
+ esac
+}
complete -F _ack ack
+complete -F _ack ack-grep
+}
View
28 squash
@@ -30,24 +30,30 @@ for my $arg ( @ARGV ) {
warn "Reading $filename\n";
open( my $fh, '<', $filename ) or die "Can't open $filename: $!";
-
+ my $in_pod = 0;
while ( <$fh> ) {
next if /^use (File::Next|App::Ack)/;
# See if we're in module POD blocks
- my $skip = ($filename ne 'ack-base') && (/^=/ .. /^=cut/);
- if ( !$skip ) {
- # Replace the shebang line and append 'no edit' comment
- if ( s{^#!.+}{#!/usr/bin/env perl} ) {
- $_ .= $NO_EDIT_COMMENT;
+ if ( $filename ne 'ack-base' ) {
+ if ( /^=(\w+)/ ) {
+ $in_pod = ($1 ne 'cut');
+ next;
}
+ elsif ( $in_pod ) {
+ next;
+ }
+ }
- # Remove Perl::Critic comments.
- # I'd like to remove all comments, but this is a start
- s{\s*##.+critic.*}{};
-
- $code .= $_;
+ # Replace the shebang line and append 'no edit' comment
+ if ( s{^#!.+}{#!/usr/bin/env perl} ) {
+ $_ .= $NO_EDIT_COMMENT;
}
+
+ # Remove Perl::Critic comments.
+ # I'd like to remove all comments, but this is a start
+ s{\s*##.+critic.*}{};
+ $code .= $_;
}
close $fh;
}
View
45 t/Util.pm
@@ -24,14 +24,20 @@ sub build_command_line {
for ( @args ) {
s/(\\+)$/$1$1/; # Double all trailing backslashes
s/"/\\"/g; # Backslash all quotes
- $_ = qq("$_");
+ $_ = qq{"$_"};
}
}
else {
@args = map { quotemeta $_ } @args;
}
- return "$^X -T ./capture-stderr $catcherr_file ./ack @args";
+ return "$^X -T ./capture-stderr $catcherr_file @args";
+}
+
+sub build_ack_command_line {
+ my @args = @_;
+
+ return build_command_line( './ack', @args );
}
sub slurp {
@@ -47,24 +53,24 @@ sub slurp {
sub run_ack {
my @args = @_;
-
+
my ($stdout, $stderr) = run_ack_with_stderr( @args );
if ( $TODO ) {
fail( q{Automatically fail stderr check for TODO tests.} );
}
else {
- is( scalar @{$stderr}, 0, 'Should have no output to stderr' )
+ is( scalar @{$stderr}, 0, "Should have no output to stderr: ack @args" )
or diag( join( "\n", "STDERR:", @{$stderr} ) );
}
- return @{$stdout};
+ return wantarray ? @{$stdout} : join( "\n", @{$stdout} );
}
-{ # scope for $AckReturnCode;
+{ # scope for $ack_return_code;
# capture returncode
-our $AckReturnCode;
+our $ack_return_code;
sub run_ack_with_stderr {
my @args = @_;
@@ -72,22 +78,23 @@ sub run_ack_with_stderr {
my @stdout;
my @stderr;
+ # The --noenv makes sure we don't pull in anything from the user.
if ( !grep { $_ =~ /^--(no)?env$/ } @args ) {
unshift( @args, '--noenv' );
}
- my $cmd = build_command_line( @args );
-
+ my $cmd = build_ack_command_line( @args );
+
@stdout = `$cmd`;
- my ($sig,$core,$rc)=( ($? & 127), ($? & 128) , ($? >> 8) );
- $AckReturnCode=$rc;
- ## XXX what do do with $core or $sig?
+ my ($sig,$core,$rc) = (($? & 127), ($? & 128) , ($? >> 8));
+ $ack_return_code = $rc;
+ ## XXX what do do with $core or $sig?
- open( CATCHERR, '<', $catcherr_file );
- while( <CATCHERR> ) {
+ open( my $fh, '<', $catcherr_file ) or die $!;
+ while ( <$fh> ) {
push( @stderr, $_ );
}
- close CATCHERR;
+ close $fh or die $!;
unlink $catcherr_file;
chomp @stdout;
@@ -95,17 +102,17 @@ sub run_ack_with_stderr {
return ( \@stdout, \@stderr );
}
-sub get_rc{
- return $AckReturnCode;
+sub get_rc {
+ return $ack_return_code;
}
-} # scope for $AckReturnCode
+} # scope for $ack_return_code
sub pipe_into_ack {
my $input = shift;
my @args = @_;
- my $cmd = build_command_line( @args );
+ my $cmd = build_ack_command_line( @args );
$cmd = "$^X -pe1 $input | $cmd";
my @results = `$cmd`;
chomp @results;
View
6 t/ack-1.t
@@ -12,11 +12,11 @@ prep_environment();
SINGLE_TEXT_MATCH: {
my @expected = (
- 'And I said: "My name is Sue! How do you do! Now you gonna die!"',
+ 'Was before he left, he went and named me Sue.'
);
my @files = qw( t/text );
- my @args = qw( Sue! -1 -h --text );
+ my @args = qw( Sue -1 -h --text );
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for first instance of Sue!' );
@@ -29,7 +29,7 @@ DASH_V: {
);
my @files = qw( t/text/boy-named-sue.txt );
- my @args = qw( Sue! -1 -h -v --text );
+ my @args = qw( Sue -1 -h -v --text );
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for first non-match' );
View
1  t/ack-binary.t
@@ -16,6 +16,7 @@ ACK_F: {
my @expected = qw(
t/etc/shebang.empty.xxx
t/swamp/moose-andy.jpg
+ t/swamp/perl.tar.gz
t/swamp/solution8.tar
);
View
15 t/ack-color.t 100755 → 100644
@@ -9,10 +9,14 @@ use File::Next ();
use lib 't';
use Util;
-plan tests => 7;
+plan tests => 10;
prep_environment();
+my $match_start = "\e[30;43m";
+my $match_end = "\e[0m";
+my $line_end = "\e[0m\e[K";
+
NORMAL_COLOR: {
my @files = qw( t/text/boy-named-sue.txt );
my @args = qw( called --color --text );
@@ -39,3 +43,12 @@ BRITISH_COLOR: {
ok( grep { /\e/ } @results, 'normal match highlighted' );
}
+MULTIPLE_MATCHES: {
+ my @files = qw( t/text/freedom-of-choice.txt );
+ my @args = qw( v.+?m|c.+?n -w --color --text );
+ my @results = run_ack( @args, @files );
+
+ is( @results, 1, 'multiple matches on 1 line' );
+ is( $results[0], "A ${match_start}victim${match_end} of ${match_start}collision${match_end} on the open sea$line_end",
+ 'multiple matches highlighted' );
+}
View
66 t/ack-column.t
@@ -0,0 +1,66 @@
+#!perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 4;
+
+use File::Next ();
+
+use lib 't';
+use Util;
+
+prep_environment();
+
+my $weasel = File::Next::reslash( 't/text/science-of-myth.txt' );
+my @base_args = qw( the -w -i --with-filename --noenv );
+
+WITH_COLUMNS: {
+ my @expected = split( /\n/, <<'HERE' );
+3:4:In the case of Christianity and Judaism there exists the belief
+6:1:The Buddhists believe that the functional aspects override the myth
+7:27:While other religions use the literal core to build foundations with
+8:11:See, half the world sees the myth as fact, and it's seen as a lie by the other half
+9:5:And the simple truth is that it's none of that 'cause
+10:24:Somehow no matter what the world keeps turning
+14:43:In fact, for better understanding we take the facts of science and apply them
+16:17:But closing off the possibilities makes it hard to see the bigger picture
+18:10:Consider the case of the woman whose faith helped her make it through
+22:31:And if it works, then it gets the job done
+23:24:Somehow no matter what the world keeps turning
+26:9: -- "The Science Of Myth", Screeching Weasel
+HERE
+ @expected = map { "${weasel}:$_" } @expected;
+
+ my @files = ( $weasel );
+ my @args = ( @base_args, '--column' );
+ my @results = run_ack( @args, @files );
+
+ lists_match( \@results, \@expected, 'Checking column numbers' );
+}
+
+
+WITHOUT_COLUMNS: {
+ my @expected = split( /\n/, <<'HERE' );
+3:In the case of Christianity and Judaism there exists the belief
+6:The Buddhists believe that the functional aspects override the myth
+7:While other religions use the literal core to build foundations with
+8:See, half the world sees the myth as fact, and it's seen as a lie by the other half
+9:And the simple truth is that it's none of that 'cause
+10:Somehow no matter what the world keeps turning
+14:In fact, for better understanding we take the facts of science and apply them
+16:But closing off the possibilities makes it hard to see the bigger picture
+18:Consider the case of the woman whose faith helped her make it through
+22:And if it works, then it gets the job done
+23:Somehow no matter what the world keeps turning
+26: -- "The Science Of Myth", Screeching Weasel
+HERE
+ @expected = map { "${weasel}:$_" } @expected;
+
+ my @files = ( $weasel );
+ my @args = ( @base_args, '--no-column' );
+ my @results = run_ack( @args, @files );
+
+ lists_match( \@results, \@expected, 'Checking without column numbers' );
+}
+
View
4 t/ack-env.t
@@ -17,7 +17,7 @@ SINGLE_TEXT_MATCH_ENV: {
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-1'; # set the parameter via the options
- my @args = qw( Sue! -h --text --env ); # and specifying --env does not change the result
+ my @args = qw( Sue! -h --text --env --nocolor ); # and specifying --env does not change the result
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for first instance of Sue! with --env' );
@@ -41,7 +41,7 @@ SEARCH_FOR_DASH_DASH_NOENV: {
my @expected = ' magic string --noenv';
my @files = qw( t/text );
local $ENV{ACK_OPTIONS} = '-h --cc'; # set the parameter via the options
- my @args = qw( -- --noenv t/swamp ); # but disable environment processing
+ my @args = qw( --nocolor -- --noenv t/swamp ); # but disable environment processing
my @results = run_ack( @args, @files );
sets_match( \@results, \@expected, 'Looking for Sue! with --noenv' );
View
2  t/ack-passthru.t
@@ -49,7 +49,7 @@ HIGHLIGHTING: {
my @ack_args = qw( July --text --passthru --color );
my @results = pipe_into_ack( 't/text/4th-of-july.txt', @ack_args );
- cmp_ok( scalar @results, '=', scalar @full_lyrics, 'Got all the lines back' );
+ is( scalar @results, scalar @full_lyrics, 'Got all the lines back' );
my @escaped_lines = grep { /\e/ } @results;
is( scalar @escaped_lines, 2, 'Only two lines are highlighted' );
View
22 t/encoding.t
@@ -0,0 +1,22 @@
+#!perl -Tw
+
+use warnings;
+use strict;
+
+use Test::More tests => 1;
+
+my $file = './ack';
+
+my $ok = 1;
+open( my $fh, '<', $file ) or die "Can't read $file: \n";
+while ( my $line = <$fh> ) {
+ chomp $line;
+ if ( $line =~ /[^ -~]/ ) {
+ my $col = $-[0] + 1;
+ diag( "$file has hi-bit characters at $.:$col" );
+ $ok = 0;
+ }
+}
+close $fh;
+
+ok( $ok, "$file has no hi-bit characters" );