From 8909a3e5c347dd6438bd92739dfed3d7bbfaf510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 23 Jul 2020 23:11:24 +0200 Subject: [PATCH] Try to avoid CodeQL warning https://github.com/cli/cli/pull/1415/checks?check_run_id=904308295 --- pkg/browser/browser.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/browser/browser.go b/pkg/browser/browser.go index 1f926c462..67ebca92f 100644 --- a/pkg/browser/browser.go +++ b/pkg/browser/browser.go @@ -20,20 +20,21 @@ func Command(url string) (*exec.Cmd, error) { // ForOS produces an exec.Cmd to open the web browser for different OS func ForOS(goos, url string) *exec.Cmd { + exe := "open" var args []string switch goos { case "darwin": - args = []string{"open"} + args = append(args, url) case "windows": - args = []string{"cmd", "/c", "start"} + exe = "cmd" r := strings.NewReplacer("&", "^&") - url = r.Replace(url) + args = append(args, "/c", "start", r.Replace(url)) default: - args = []string{"xdg-open"} + exe = "xdg-open" + args = append(args, url) } - args = append(args, url) - cmd := exec.Command(args[0], args[1:]...) + cmd := exec.Command(exe, args...) cmd.Stderr = os.Stderr return cmd }