From fdd9ecb3a5b5a3536fb0a27afd37e3d3a88e324b Mon Sep 17 00:00:00 2001 From: AI Bot Date: Sun, 19 Apr 2026 11:08:32 +0200 Subject: [PATCH] Handle pacman -Qdtq exit code 1 as non-error pacman -Qdtq exits with code 1 when there are no orphans, which is not an error condition. Handle this gracefully by returning nil instead of an error. --- pkg/pacman/read/read.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/pacman/read/read.go b/pkg/pacman/read/read.go index c358d98..9ce707f 100644 --- a/pkg/pacman/read/read.go +++ b/pkg/pacman/read/read.go @@ -1,6 +1,8 @@ package read import ( + "bytes" + "errors" "fmt" "os" "os/exec" @@ -38,8 +40,16 @@ func ListOrphans() ([]string, error) { log.Debug("ListOrphans: starting...") cmd := exec.Command("pacman", "-Qdtq") + var stderr bytes.Buffer + cmd.Stderr = &stderr + output, err := cmd.Output() if err != nil { + // pacman -Qdtq exits 1 when there are no orphans, this isnt an error + var exitErr *exec.ExitError + if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 && stderr.Len() == 0 { + return nil, nil + } return nil, err }