Fixed pass to Pacman

This commit is contained in:
Jguer 2016-10-02 18:19:26 +01:00
parent 95b222c70c
commit 5b60bb6781
2 changed files with 19 additions and 6 deletions

View file

@ -127,13 +127,26 @@ func (s *RepoSearch) PrintSearch(mode int) {
} }
} }
func passToPacman(op string, flags string) error { func passToPacman(op string, pkg string, flags string) error {
var cmd *exec.Cmd var cmd *exec.Cmd
if flags == "" { var args []string
cmd = exec.Command("sudo", "pacman", op)
} else { args = append(args, op)
cmd = exec.Command("sudo", "pacman", op, flags) if pkg != "" {
args = append(args, pkg)
} }
if flags != "" {
args = append(args, flags)
}
if strings.Contains(op, "Q") {
cmd = exec.Command("pacman", args...)
} else {
args = append(args, "pacman")
cmd = exec.Command("sudo", args...)
}
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr

2
yay.go
View file

@ -87,7 +87,7 @@ func main() {
case "yogurt": case "yogurt":
err = searchAndInstall(pkg, &conf, flag) err = searchAndInstall(pkg, &conf, flag)
default: default:
fmt.Println("Pass to pacman") err = passToPacman(op, pkg, flag)
} }
if err != nil { if err != nil {