ack3 icon indicating copy to clipboard operation
ack3 copied to clipboard

Add a -X that acts like -x but obeys the --type filters

Open petdance opened this issue 1 year ago • 4 comments

ack -x ignores type filters. This is surprising to some users, and there have been repeated calls for -x to respect the --type filters.

It's too late to change the behavior of -x, but perhaps we add another flag, maybe -X, that obeys the type filters.

Let's discuss.

petdance avatar Mar 26 '23 23:03 petdance

I might ask to consider having the flag be independent of -x - this behavior is also confusing on the command line.

(Also, this way it can be embeded in ackrc)

jakebman avatar Mar 27 '23 05:03 jakebman

What does "independent of -x" mean? Which behavior is also confusing on the command line? Which way it can be embedded in ackrc?

petdance avatar Mar 30 '23 03:03 petdance

Independent of -x: -x is just a specialization of --files-from, right? It feels weird to have type filtering apply only to stdin, and not any other file you could read your starting set from.
I'd really like it if it could be applied to any other --files-from, and additionally to the starting set specified on the command line (otherwise the "consistent with *.pl --noperl" consistency is broken)

Behavior on the command line: It's confusing that --noperl doesn't exclude .pl files from a starting set. This behavior is equally confusing from the command line and -x. This behavior is surprising/confusing/non-DWIM in both contexts, and I'm asking for a fix to it to be considered to be able to resolved in both contexts.

Specify in ackrc: Even though we can't break existing scripts, I personally want this feature to be the default ack behavior, and that's what ackrc is for: to have personal default settings. Having this as an independent flag I can tuck into my ackrc basically gives me that power. I wouldn't be able to do that with -X.

None of this is an argument against -X as a new flag. I'm just asking to consider making the behavior broader (to cover --files-from, and the CLI starting set), and allow -X to mean "-x, but respecting type filters" in the same way that --some-new-flag-name would cause type filters to be respected in non-stdin --files-from, or on the CLI.

jakebman avatar Apr 13 '23 01:04 jakebman

Ability to use ack type filters in xargs mode is some setting i'd use. Our filters are more expressive than e.g. finds.

n1vux avatar May 04 '23 14:05 n1vux