Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-x and --type=format options should be mutex #367

Open
petdance opened this issue Mar 16, 2023 · 4 comments
Open

-x and --type=format options should be mutex #367

petdance opened this issue Mar 16, 2023 · 4 comments
Labels

Comments

@petdance
Copy link
Collaborator

If I have something like this:

cat filelist.txt | ack -x --noperl

I will be surprised that the --noperl does nothing because -x already knows it is getting files from stdin, and does no filtering. I should get a mutex warning that -x and --noperl can't be used together.

@n1vux
Copy link
Contributor

n1vux commented Mar 16, 2023

this is consistent with the behavior of ack -f --noperl *.pl

but one can argue that according to Principle of Least Surprise, we're consistently wrong, that file type filters should apply to (supposedly) explicit file lists (including -x xargs ).

@jakebman
Copy link

@n1vux - adding my vote on feeling consistently surprised by this feature.

Would it make more sense if we consider CLI arguments are really intended to bypass --ignore rules (especially those that are default or came from .ackrc), and not the --type/-T arguments that are more commonly specified at the time of the query?

This would make the following invocations equivalent, which seems clean to me. Currently, only the single one diverges from the rest of them.

ack -f --type=json | ack -x foo
ack -f | ack -x --type=json foo         # doesn't work today :(
ack --type=json foo

(caveat - only the last form can handle filenames with newlines in them 😞. Would it be pushing it to ask for find's --files0-from or xarg's -0/--null while we're here?)

Also, it'd be really nice if git ls-files | ack -x --type=json foo DWYM.

@petdance
Copy link
Collaborator Author

ack -f | ack -x --type=json foo # doesn't work today :(

Please, don't conflate "doesn't work" with "doesn't do what I want it to do." ack -x works exactly as I intended it.

@petdance
Copy link
Collaborator Author

I've added a new ticket #368 for discussing a new flag that could act like -x but obey the type filters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants