(Related to bug #113032, but reported as a new bug because it's really separate now with simply the same inspiration.) Attached is a patch for gentoolkit 0.2.1_rc1 which implements an additional option --partial-name for equery list. It's useful for users not familiar with regexes; equery list --partial-name <argument> is basically equivalent to equery list --full-regex '.*<argument>.*' except that the argument is automatically escaped if --full-regex is not given. Good idea? Bad idea? Other comments?
Created attachment 73281 [details, diff] The patch
Perfect -- now equery is easier to use than qpkg. Thanks!
I think the patch is a good idea. The only question in my mind is do we make this behavior the default and switch the current default behavior to be an option?
That sounds like a good idea. It might cause problems if scripts rely on the current behaviour, but personally, I doubt there are any such scripts yet. Using --full-name for such an option may make the meaning of --full-regex unclear, by the way. What would be the right thing to call it?
My thinking would be to call the option --exact-name
Created attachment 73376 [details, diff] gentoolkit-0.2.1_rc1-partialname-default.patch Attached is a patch against rc1 that makes partial name matching the default behavior. The option to get the current behavior is -e or --exact-name.
I like it. Just to make sure I understand: your -e flag does not expect or want regexps, right? I can use regexps fine with -f but not with -e. This makes good sense to me, but I just want to make sure everyone agrees. As for the default behavior, it's perfect AFAICT. It even finds the right packages when I search for + or ++ so this seems a big improvement over qpkg.
Thanks for updating the patch. I like the --exact-name option name. And: > Just to make sure I understand: your -e flag does not expect or want > regexps, right? I can use regexps fine with -f but not with -e. This makes good > sense to me, but I just want to make sure everyone agrees. It's probably the best way to go. If you want to use -e with regexes, you can simply pass both the -e and the -f option.
Fixed in gentoolkit-0.2.1_rc2
I changed the behavior slightly before committing. Using --full-regex implies --exact-name, otherwise regular expression searches didn't work correctly. However, using --exact-name does not imply that you are using a regular expression.
> I changed the behavior slightly before committing. Using --full-regex implies > --exact-name, otherwise regular expression searches didn't work correctly. Ah, okay. I had tried it, but apparently not well enough :) If you could give me an example of what fails, I'll try to find a fix for a future version.
Okay, I must have been smoking something since I can't find what regular expression that I was using to cause problems. I know that it had to do with using '+' and '*' but everything I've tried appears to be working correctly. So the question becomes, do we want to have partial name matching be the default for regular expressions as well or have them be exact matches?
Making exact matches the default for regexes would require adding a -E/--no-exact-name option in addition to the --exact-name option, and even though exact matches are probably more useful with regexes, the interaction between -e, -E, and -f may cause unnecessary confusion. For example, what would equery list -E -f do? Both partial and exact matching would be a reasonable choice, I think, so it would not be clear (at least to me) what it would actually do. And having partial matches as the default regardless of whether regexes are used is easier to implement :)
Wow, it's much better now, thanks!
Partial name matching is now default for reqular expressions as well. Will be released with gentoolkit-0.2.1_rc3