-
Notifications
You must be signed in to change notification settings - Fork 66
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
Make --ignore-dir operate the entire path, not just relative #329
Comments
I'm not following. What exactly is it you're wanting ack to do? |
Sorry, the feature I'm referring to is: using For instance, with a dir tree like this:
I'd like to be able to write: |
Please note that you don't need the |
So if I'm understanding correctly, given this setup:
You want:
|
That's correct, as long as I read the In truth, I'm more interested in excluding via elaborate regex matches rather than including, but I imagine the syntax would be largely the same. There is also the issue of relative paths and putting such expressions in .ackrc, which is mentioned in that IGNORE.md file I mentioned. Personally, it makes sense to me that such paths would be relative to that .ackrc file, but that's just my 2¢. |
I've had the same problem.
Maybe something like --ignore-path would be possible without braking things? |
+1 from me. In my use case, the top folder of the source tree is 'build', which I want to ignore (and everything under it), but 'build' is such a common name that I don't want to risk someone creating it in the source folders. |
I'm open to suggestions on how this feature would work without breaking existing usage. I'm talking about discussion of how the feature would work, not actual code yet. |
If you introduce a new switch, --ignore-path, then it won't affect existing usage |
So let's talk this out in specifics. You have the tree you showed above:
So then you'd call Because what if you want to search |
--ignore-path will be a pattern that would match against the paths that One apprach can ge: if it starts with '/', then it is absolute (same as adding a '^' in a regular expression), otherwise it matches an subpath. So Another approach is to support regex. Then the user decides if they want to use '^' or not |
I agree with this, and it's consistent with other unix tools, such as As mentioned earlier, it might make sense to have paths in Regarding absolute paths: it might be worthwhile to include support for these, if reasonable. None of my personal use cases for this feature require absolute paths, but I could see it mattering to some people. One small nuance, here: There are at least 3 different "start of path" anchor points for pattern matching that are worth considering:
So, to be concrete, in the example hierarchy (with some additions), here are some test cases:
For @ittayd's example of a
Note: None of the above examples use true "absolute path". They all treat the invocation directory as the base dir (akin to Some open questions, in my mind:
|
Oh, and to specifically answer this bit, with the above in mind:
I would imagine, from the top dir: Or if you wanted to ignore all So, going back to a high-level description, my leanings are:
|
I'm not sure why this needs to be so complicated. Ack already has an established way of discovering paths. '-f' will output them. All --ignroe-path needs to do is to match against that list. Having it be a regex seems inconvenient as users would need to pepper ''[^/]". Seems to me that either globbing, or a set of regexs separated by '/' will be OK. (For the latter it means the pattern 'f.*o/b.*r' will be split to 'f.*o' and 'b.*r' which will be patched on consecutive path elements which of course makes the whole thing more complex/expensive (unless there's a nice way to create an FSM that treats only verbatim slashes) |
I hope it's not, but past experience has shown that what seems simple is rarely so. Matching ack does not do globbing at all in its matching. |
Sorry, I didn't mean my long discussion to make it seem hairier than it is (: I think the essence of the examples I wrote is "make it behave much like FWIW, I am fine with no globbing (regex is strictly more powerful anyway). I do think the "relative to the .ackrc file" concept is useful, when invoking |
Thing is that there can be multiple .ackrc files. And even if there's only one, there's no rule that says it has to be in the root of the project. "make it behave much like find . | grep -v ..." is a good principle, since that's basically how |
Yes, I understand. But I don't think it is necessarily a problem? Conceptually, I imagine each "--ignore-path=..." option found in an For instance, when ack finally does its matching work, I am imagining it has gathered a list of And also, just as I'm thinking about it, I could imagine cases where people do want to put paths in their |
I'm not sure the best place to put my comments, so making this issue.
Feel free to close if you feel it's all well enough represented in other places.
I was tracking the trail of ack2#330 → #7 →split into #88 and #89, and didn't find explicit reference to the notion of matching full directory paths for
--ignore-dir
in the still-open issues.I did find the IGNORE.md document, which gives me the impression the path forward is not entirely clear.
Anyway, just wanted to make sure something tracks that feature request, since it's one I'd certainly like (:
The text was updated successfully, but these errors were encountered: