1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-15 06:52:43 +01:00

nix search: explicitly handle empty search string, fixes #1893

This is important since this is given as an example.
Other patterns containing "empty search string" will still
be handled differently on different platforms ("asdf|")
but that's less of an issue.

(cherry picked from commit 009cf9cd23)
This commit is contained in:
Will Dietz 2018-02-25 16:38:13 -06:00 committed by Eelco Dolstra
parent e9c5be6fe7
commit bdd88cabd3
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

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();