diff options
Diffstat (limited to 'src/nix/search.cc')
-rw-r--r-- | src/nix/search.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc index 0fbd3b6c0..5ccf1b7cf 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(); @@ -234,7 +239,7 @@ struct CmdSearch : SourceExprCommand, MixJSON throw Error("error writing to %s", tmpFile); } - if (rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1) + if (writeCache && rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1) throw SysError("cannot rename '%s' to '%s'", tmpFile, jsonCacheFileName); } |