From 104e55bb7f593b1ac3c54ffda48a9d72af7fbe6b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Oct 2014 18:47:16 +0200 Subject: nix-env: Add regular expression support in selectors So you can now do things like: $ nix-env -qa '.*zip.*' $ nix-env -qa '.*(firefox|chromium).*' --- src/libexpr/names.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libexpr') diff --git a/src/libexpr/names.cc b/src/libexpr/names.cc index 781c2b6468f9..c2b2733347f6 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; } -- cgit 1.4.1