From 824b31c50f746786bbd31ee5fc13e111846b3cb5 Mon Sep 17 00:00:00 2001 From: yory8 <> Date: Tue, 17 Sep 2019 13:28:34 +0200 Subject: [PATCH] fix(selector): don't spawn wl-copy if no selection --- main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 815de64..3197175 100644 --- a/main.go +++ b/main.go @@ -66,9 +66,11 @@ func main() { log.Fatal(err) } - // serve selection to the OS - if err := exec.Command("wl-copy", []string{"--", selection}...).Run(); err != nil { - log.Fatal(err) + if selection != "" { + // serve selection to the OS + if err := exec.Command("wl-copy", []string{"--", selection}...).Run(); err != nil { + log.Fatal(err) + } } case "clear": histfile, history, err := getHistory(*histpath) @@ -89,8 +91,10 @@ func main() { log.Fatal(err) } - if err := write(filter(history, selection), histfile); err != nil { - log.Fatal(err) + if selection != "" { + if err := write(filter(history, selection), histfile); err != nil { + log.Fatal(err) + } } } }