aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-03 18:47:16 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-03 21:29:40 +0200
commit104e55bb7f593b1ac3c54ffda48a9d72af7fbe6b (patch)
tree92eea5af2736190ec196a4bc68c16ea5f16dff2f /src/libexpr
parent3800f441e49af78b95d403014459dbb9bb646e8a (diff)
nix-env: Add regular expression support in selectors
So you can now do things like: $ nix-env -qa '.*zip.*' $ nix-env -qa '.*(firefox|chromium).*'
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/names.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libexpr/names.cc b/src/libexpr/names.cc
index 781c2b646..c2b273334 100644
--- a/src/libexpr/names.cc
+++ b/src/libexpr/names.cc
@@ -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;
}