Repositories / jai.git

jai.git

Clone (read-only): git clone http://git.guha-anderson.com/git/jai.git

Branch

fix environment variable completion

Author
David Mazieres <dm@uun.org>
Date
2026-03-26 17:07:12 -0700
Commit
55154018fe37ffb07e2f1c0f9aa41feb51f575cd
complete.cc
index a5f8904..81013ca 100644
--- a/complete.cc
+++ b/complete.cc
@@ -70,14 +70,15 @@ complete_config(int cfd, CompSet &c, std::string ext)
 static void
 complete_env(CompSet &c, bool eq)
 {
-  std::string_view arg;
+  std::string_view arg = c.arg();
   for (char **e = environ; *e; ++e) {
     std::string_view var = *e;
     if (auto pos = var.find('='); pos == var.npos)
       continue;
     else
       var = var.substr(0, eq ? pos + 1 : pos);
-    c.output("{}", var);
+    if (var.starts_with(arg))
+      c.output("{}", var);
   }
 }