ericm / yup

Arch Linux AUR Helper with ncurses functionality and better searching and sorting
https://aur.archlinux.org/packages/yup
GNU General Public License v3.0
139 stars 7 forks source link

Yup -c failed when there is no unused dependencies to uninstall #20

Closed Galiley closed 4 years ago

Galiley commented 4 years ago

The issue is in the file clean/clean.go

// Clear unused packs
output.Printf("Finding unused dependencies")
pac := exec.Command("pacman", "-Qtdq")
var packs []string
if out, err := pac.Output(); err == nil {
    for _, pack := range strings.Split(string(out), "\n") {
        if len(pack) > 1 {
            packs = append(packs, pack)
        }
    }
}

When there is no unused dependencies, packs should be empty

packs = append([]string{"pacman", "-Rns"}, packs...)
rem := exec.Command("sudo", packs...)
output.SetStd(rem)
if err := rem.Run(); err != nil {
    return err
}

return nil

This statement should be run only if packs isn't empty.