about summary refs log tree commit diff
diff options
context:
space:
mode:
-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();