Matthew Hall
I use ack on some big multi-GB repositories which contain a whole ton of ancillary things of dubious utility that I can't necessarily delete or remove or relocate, for example, XML files, script files written in DSLs, JSON files, random test data files, etc. which are technically text, but full of an awful lot of junk I wouldn't want to search by default because it will take lots longer. And they could have a whole lot of arbitrary names and extensions I don't care about because they're not the sort of classic extensions used on code.
Searching all these somewhat defeats the purpose of ack, because I liked the way it tossed out mostly-useless non-code files by default. Of course it's good you have the -k option to bring back the old behavior.
But unfortunately at the same time, -a and -u were ripped out. So then you don't have a nice way of putting -k in .ackrc, and only overriding -k and no other flags (like fully disabling .ackrc would cause) when you really do want to search through all the cruft to ferret out something obscure.
Packy Anderson
Ideally, I'd love to be able to say --noknown-types on the command line and have it override the --known-types in my .ackrc. When ack2 came out, the default switched from the behavior I wanted as a coder (searching only known types) to the behavior all the non-coders looking for a grep replacement were expecting (searching everything). I accepted this as a good thing because it made ack's defaults match what the majority of users were expecting, and the good of the many outweigh the good of the few, even when the few includes me.
This pleased me until I had to look for a file ... I knew ... wouldn't have an extension, so, reflexively, I typed ack -a. Bzzzzt! I typed an ack --bar to make myself feel better and then consulted ack --help. Looking at the options, I decided to try --noknown-types to see if it was an undocumented feature. No dice. Eventually, I had to settle for --noenv and do without my other .ackrc defaults, and I found my file.
I guess what I find confusing is why a Boolean option that's either on or off shouldn't accept the no prefix to negate its meaning. Looking at the code, I see that supporting --noknown-types would be more work because it's not specified as 'k|known-types!' => \$somevar, but it doesn't look like much more. In fact, adding this should fix it:
$additional_specs{'noknown-types'} = sub {
my ( undef, $value ) = @_;
$opt->{'filters'} = [ ];
};
So I'm asking: is there a reason why --known-types, which was added to allow the user to revert to ack 1.x behavior, isn't negatable? I understand ... changing the default behavior, and I understand adding an option to bring the old behavior back, but I don't understand why a user can't override the default in their .ackrc... . They either have to eschew all their custom settings (--noenv) or create a custom .ackrc for what's probably a one-off search.
Setting the default behavior to what most users expect is good, allowing sophisticated users to override those defaults to suit themselves is better, but then allowing power users to override their own defaults on an invocation by invocation basis is BEST (imho).
Andy Lester
So, we need -K/--no-known-types.
Someone make a ticket for it please.
Matthew Hall
I use ack on some big multi-GB repositories which contain a whole ton of ancillary things of dubious utility that I can't necessarily delete or remove or relocate, for example, XML files, script files written in DSLs, JSON files, random test data files, etc. which are technically text, but full of an awful lot of junk I wouldn't want to search by default because it will take lots longer. And they could have a whole lot of arbitrary names and extensions I don't care about because they're not the sort of classic extensions used on code.
Searching all these somewhat defeats the purpose of ack, because I liked the way it tossed out mostly-useless non-code files by default. Of course it's good you have the
-koption to bring back the old behavior.But unfortunately at the same time,
-aand-uwere ripped out. So then you don't have a nice way of putting-kin.ackrc, and only overriding-kand no other flags (like fully disabling.ackrcwould cause) when you really do want to search through all the cruft to ferret out something obscure.Packy Anderson
Ideally, I'd love to be able to say
--noknown-typeson the command line and have it override the--known-typesin my.ackrc. Whenack2came out, the default switched from the behavior I wanted as a coder (searching only known types) to the behavior all the non-coders looking for a grep replacement were expecting (searching everything). I accepted this as a good thing because it madeack's defaults match what the majority of users were expecting, and the good of the many outweigh the good of the few, even when the few includes me.This pleased me until I had to look for a file ... I knew ... wouldn't have an extension, so, reflexively, I typed
ack -a. Bzzzzt! I typed anack --barto make myself feel better and then consultedack --help. Looking at the options, I decided to try--noknown-typesto see if it was an undocumented feature. No dice. Eventually, I had to settle for--noenvand do without my other.ackrcdefaults, and I found my file.I guess what I find confusing is why a Boolean option that's either on or off shouldn't accept the
noprefix to negate its meaning. Looking at the code, I see that supporting--noknown-typeswould be more work because it's not specified as'k|known-types!' => \$somevar,but it doesn't look like much more. In fact, adding this should fix it:So I'm asking: is there a reason why
--known-types, which was added to allow the user to revert to ack 1.x behavior, isn't negatable? I understand ... changing the default behavior, and I understand adding an option to bring the old behavior back, but I don't understand why a user can't override the default in their .ackrc... . They either have to eschew all their custom settings (--noenv) or create a custom .ackrc for what's probably a one-off search.Setting the default behavior to what most users expect is good, allowing sophisticated users to override those defaults to suit themselves is better, but then allowing power users to override their own defaults on an invocation by invocation basis is BEST (imho).
Andy Lester
So, we need -K/--no-known-types.
Someone make a ticket for it please.