diff options
author | Will Dietz <w@wdtz.org> | 2018-02-25 16:38:13 -0600 |
---|---|---|
committer | Will Dietz <w@wdtz.org> | 2018-02-25 16:40:56 -0600 |
commit | 009cf9cd23e5b9198cf8977cca7c823b6b95ad5b (patch) | |
tree | d8fbe16eeb79ead246dae28b4d1703e73523391a /src | |
parent | 3cac8734acb098488bd232bcee92099410d4d167 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/nix/search.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc index 1adde28cb..009dfae9c 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(); |