Catch beginner mistakes with warnings #200

hoelzro opened this Issue Jan 21, 2013 · 1 comment


None yet

2 participants

hoelzro commented Jan 21, 2013

Detect when file selectors aren't used

When an explicit target list of only files is used, file selectors such as --type=perl, --ruby, or --ignore-dir=blib are not consulted. For example:

ack foo --ruby

The --ruby is valid, but because is specified on the command, it is not type-checked. To the user's eyes, the --ruby is broken because ack still searched Perl file.

Detect when a normally ignored directory is specified on the command line

In the case of this invocation:

ack foo --perl blib/

blib/ will be searched, because it is specified on the command line. However, a warning stating that "blib is normally ignored, but will be searched anyway" would be handy.

Detect when a user specifies a relative/absolute path to --ignore-dir/--ignore-file

See also #291 and #330.

Add --warnings/--no-warnings

If we're going to have warnings, we should probably have a way of turning them off.


FWIW, contrary to the above, at least under current versions of ack 2.x, ack foo --perl blib/ does NOT still search blib/ (and I even tried using --noenv to make sure it wasn't just me, hehe!)

~/src/ack2> ./ack-standalone foo --perl blib/
1: This file has some foo in it
~/src/ack2> ./ack-standalone --noenv foo --perl blib/
1: This file has some foo in it

You have to use --ignore-ack-defaults (which breaks --perl) or --noignore-dir=blib:

~/src/ack2> ./ack-standalone --ignore-ack-defaults foo --perl blib/
Unknown option: perl
ack-standalone: Invalid option on command line
~/src/ack2> ./ack-standalone --noignore-dir=blib foo --perl blib/
1: This file has some foo in it

193:        # and say "ack foo whatever.jpg" it will do it for you.
1319:directories like F<foo/bar> are NOT supported. You would need to
1320:specify B<--ignore-dir=foo> and then no files from any foo directory
1355:    # search for foo and bar in given files
1356:    ack file1 t/file* --match foo
1452:If a file is of both type "foo" and "bar", specifying --foo and
1551:I<ack --perl foo> searches for foo in all perl files. I<ack --help=types>
1554:files as well when searching for --perl files? I<ack --type-add perl:ext:xs --perl foo>
1908:example, to change all "foo" to "bar" in all PHP files, you can do
1911:    $ perl -i -p -e's/foo/bar/g' $(ack -f --php)
1958:=head2 Why is ack telling me I have an invalid option when searching for C<+foo>?

This is with a fresh-from-the-master-branch ack 2.13_06:

~/src/ack2> ./ack-standalone --version
ack 2.13_06
Running under Perl 5.18.1 at /Users/dabe/perl5/perlbrew/perls/perl-5.18.1/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.

I see it DOES still work that way under ack 1.96, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment