1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

Merge pull request #1906 from dtzWill/fix/nix-search

nix search: tests and fix #1893 and part of #1892
This commit is contained in:
Shea Levy 2018-03-13 18:43:47 -06:00 committed by GitHub
commit 56f2ed0081
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 2 deletions

View file

@ -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);
}