fix(selector): don't spawn wl-copy if no selection

This commit is contained in:
yory8 2019-09-17 13:28:34 +02:00
parent 11ad8149ad
commit 824b31c50f

14
main.go
View file

@ -66,9 +66,11 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
// serve selection to the OS if selection != "" {
if err := exec.Command("wl-copy", []string{"--", selection}...).Run(); err != nil { // serve selection to the OS
log.Fatal(err) if err := exec.Command("wl-copy", []string{"--", selection}...).Run(); err != nil {
log.Fatal(err)
}
} }
case "clear": case "clear":
histfile, history, err := getHistory(*histpath) histfile, history, err := getHistory(*histpath)
@ -89,8 +91,10 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
if err := write(filter(history, selection), histfile); err != nil { if selection != "" {
log.Fatal(err) if err := write(filter(history, selection), histfile); err != nil {
log.Fatal(err)
}
} }
} }
} }