aboutsummaryrefslogtreecommitdiff
path: root/src/nix/search.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 08:40:12 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 08:40:12 +0100
commit044c117a9f8ae92241076b2afa1a419cdc912c5e (patch)
tree860bf29fabe4506f43505e83554e099bfec927a6 /src/nix/search.cc
parent20d7b93b0c83db3d620009e440263d7ab8faeec6 (diff)
Merge pull request #9481 from iFreilicht/disallow-nix-search-without-search-terms
nix search: Disallow empty regex (cherry picked from commit 1c260fa6d1f47d83954792771d0614db163cc3bc) Change-Id: Iaaf3605c24a342fcb05d0b534a9f305533d3b5fa
Diffstat (limited to 'src/nix/search.cc')
-rw-r--r--src/nix/search.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc
index ef0139e09..97ef1375e 100644
--- a/src/nix/search.cc
+++ b/src/nix/search.cc
@@ -67,11 +67,9 @@ struct CmdSearch : InstallableValueCommand, MixJSON
settings.readOnlyMode = true;
evalSettings.enableImportFromDerivation.setDefault(false);
- // 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)
+ // Recommend "^" here instead of ".*" due to differences in resulting highlighting
if (res.empty())
- res.push_back("^");
+ throw UsageError("Must provide at least one regex! To match all packages, use '%s'.", "nix search <installable> ^");
std::vector<std::regex> regexes;
std::vector<std::regex> excludeRegexes;