nix/search: no error for empty search results if json is enabled

- result list will be always empty if --json is passed
- for scripts an empty search result is not really an error,
  we rather want to distinguish between evaluation errors and empty results
This commit is contained in:
Jörg Thalheim 2020-05-05 12:09:46 +01:00
parent a721a0b114
commit 85c1932c94
No known key found for this signature in database
GPG key ID: 003F2096411B5F92

View file

@ -265,7 +265,7 @@ struct CmdSearch : SourceExprCommand, MixJSON
throw SysError("cannot rename '%s' to '%s'", tmpFile, jsonCacheFileName);
}
if (results.size() == 0)
if (!json && results.size() == 0)
throw Error("no results for the given search term(s)!");
RunPager pager;