--type
(or --type-add
) for files with no extension?
#1967
-
I'd like to search a folder for some C++ code. It also has a great deal of other code, so I'd like to limit it to just the C++, as you'd normally do with -tcpp. Unfortunately, some1 of these files are in a pseudo c++-stdlib, and the convention for the C++ standard library is for the contents to have no file extension2. So, I'd like to do something like It feels like it would be nice if something for this existed in the builtin list (probably with a better name than I think there's a reasonable chance this is possible with the glob, but my glob-fu was just too weak. It's also quite possibly doable through other means I didn't think of. (And if neither of those is true, then maybe something should be added? It's an edge case, but not an inconceivable one) 1: In fact, plausibly the ones holding the data I'm looking for, although I'm not sure. (I have to check several branches, which is why I'd like a better method here). 2: In case you doubt this, see most of the files inside https://github.com/llvm/llvm-project/tree/main/libcxx/include. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So the first thing I did was find a query that gives me a hit in a
So with that in our back pocket, I don't think there is any way to express "match a file name without an extension" in the glob syntax supported by ripgrep. The problem is that standard globbing (leaving out "extended glob" syntax) is fundamentally limited. The only repetition operators are
So you might think you can compose this with
But this doesn't quite work because once a whitelist rule is introduced (that's the However, globs are applied in precedence order. And since
So this is in effect saying, "if a path has a cpp extension, search it. Otherwise, if a path has any |
Beta Was this translation helpful? Give feedback.
So the first thing I did was find a query that gives me a hit in a
.cpp
file, a hit in a cpp file with no extension and a hit in a non-cpp file:So with that in our back pocket, I don't think there is any way to express "match a file name without an extension" in the glob syntax supported by ripgrep. The problem is…