diff main.cpp @ 2:00b62a080354

fix numerous bugs
author Yasuri <yasuri@charliesmp.net>
date Sun, 13 Sep 2026 19:40:11 +0000
parents 21b543c7aa14
children ae3a6d7bcca6
line wrap: on
line diff
--- a/main.cpp	Sun Sep 13 19:25:50 2026 +0000
+++ b/main.cpp	Sun Sep 13 19:40:11 2026 +0000
@@ -9,9 +9,9 @@
 }
 int main() {
     char* const query_argv[] = { const_cast<char*>("xbps-query"), const_cast<char*>("-Rs"), const_cast<char*>(""), nullptr };
-    std::string package_list = run_piped("/usr/bin/xbps-query", query_argv, ""); 
+    std::string package_list = run_piped(query_argv, ""); 
     char* const fzf_argv[] = { const_cast<char*>("fzf"), nullptr };
-    std::string result = run_piped("/usr/bin/fzf", fzf_argv, package_list);
+    std::string result = run_piped(fzf_argv, package_list);
 
     // strip trailing newline fzf adds
     if (!result.empty() && result.back() == '\n') {
@@ -25,7 +25,18 @@
         pkgname.data(),
         nullptr
     };
-    std::string status = spawn(install_argv, "/usr/bin/doas");
-
+    std::string status = spawn(install_argv);
+    if (status == "error") {
+        std::cerr << "failed to launch doas/xbps-install\n";
+        return 1;
+    }
+    if (status.rfind("sig:", 0) == 0) {
+        std::cerr << "xbps-install was killed by signal " << status.substr(4) << "\n";
+        return 1;
+    }
+    if (status != "0") {
+        std::cerr << "xbps-install exited with code " << status << "\n";
+        return 1;
+    }
     return 0;
 }