about summary refs log tree commit diff
path: root/src/nix
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2018-02-25T22·38-0600
committerWill Dietz <w@wdtz.org>2018-02-25T22·40-0600
commit009cf9cd23e5b9198cf8977cca7c823b6b95ad5b (patch)
treed8fbe16eeb79ead246dae28b4d1703e73523391a /src/nix
parent3cac8734acb098488bd232bcee92099410d4d167 (diff)
nix search: explicitly handle empty search string, fixes #1893
This is important since this is given as an example.
Other patterns containing "empty search string" will still
be handled differently on different platforms ("asdf|")
but that's less of an issue.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/search.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc
index 1adde28cb3ca..009dfae9cf40 100644
--- a/src/nix/search.cc
+++ b/src/nix/search.cc
@@ -78,6 +78,11 @@ struct CmdSearch : SourceExprCommand, MixJSON
     {
         settings.readOnlyMode = true;
 
+        // Empty search string should match all packages
+        // Use "^" here instead of ".*" due to differences in resulting highlighting
+        // (see #1893 -- libc++ claims empty search string is not in POSIX grammar)
+        if (re.empty()) re = "^";
+
         std::regex regex(re, std::regex::extended | std::regex::icase);
 
         auto state = getEvalState();