mirror of
https://github.com/NixOS/nix
synced 2025-06-28 09:31:16 +02:00
nix-env: Add regular expression support in selectors
So you can now do things like: $ nix-env -qa '.*zip.*' $ nix-env -qa '.*(firefox|chromium).*'
This commit is contained in:
parent
3800f441e4
commit
104e55bb7f
5 changed files with 165 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "names.hh"
|
||||
#include "util.hh"
|
||||
#include "regex.hh"
|
||||
|
||||
|
||||
namespace nix {
|
||||
|
@ -32,7 +33,10 @@ DrvName::DrvName(const string & s) : hits(0)
|
|||
|
||||
bool DrvName::matches(DrvName & n)
|
||||
{
|
||||
if (name != "*" && name != n.name) return false;
|
||||
if (name != "*") {
|
||||
Regex regex(name);
|
||||
if (!regex.matches(n.name)) return false;
|
||||
}
|
||||
if (version != "" && version != n.version) return false;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue