We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6983212 commit da95f49Copy full SHA for da95f49
browser_linux.go
@@ -1,14 +1,22 @@
1
package browser
2
3
import (
4
+ "os"
5
"os/exec"
6
)
7
8
func openBrowser(url string) error {
- sensibleBrowser, err := exec.LookPath("sensible-browser")
9
- if err != nil {
10
- // sensible-browser not availble, try xdg-open
11
- return exec.Command("xdg-open", url).Run()
+ // try sensible-browser first
+ if err := runCmd("sensible-browser", url); err == nil {
+ return nil
12
}
13
- return exec.Command(sensibleBrowser, url).Run()
+ // sensible-browser not availble, try xdg-open
14
+ return runCmd("xdg-open", url)
15
+}
16
+
17
+func runCmd(prog string, args ...string) error {
18
+ cmd := exec.Command(prog, args...)
19
+ cmd.Stdout = os.Stdout
20
+ cmd.Stderr = os.Stderr
21
+ return cmd.Run()
22
0 commit comments