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:
commit
56f2ed0081
4 changed files with 71 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue