Update exec.Command on all OSes
This commit is contained in:
		@@ -1,5 +1,3 @@
 | 
			
		||||
// +build !windows,!darwin
 | 
			
		||||
 | 
			
		||||
// gomuks - A terminal Matrix client written in Go.
 | 
			
		||||
// Copyright (C) 2020 Tulir Asokan
 | 
			
		||||
//
 | 
			
		||||
@@ -20,16 +18,22 @@ package open
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os/exec"
 | 
			
		||||
 | 
			
		||||
	"maunium.net/go/gomuks/debug"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Open(input string) error {
 | 
			
		||||
	cmd := exec.Command("xdg-open", input)
 | 
			
		||||
	cmd := exec.Command(Command, append(Args, input)...)
 | 
			
		||||
	err := cmd.Start()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		debug.Print("xdg-open error:", err)
 | 
			
		||||
		debug.Printf("Failed to start %s: %v", Command, err)
 | 
			
		||||
	} else {
 | 
			
		||||
		go cmd.Wait()
 | 
			
		||||
		go func() {
 | 
			
		||||
			waitErr := cmd.Wait()
 | 
			
		||||
			if waitErr != nil {
 | 
			
		||||
				debug.Printf("Failed to run %s: %v", Command, err)
 | 
			
		||||
			}
 | 
			
		||||
		}()
 | 
			
		||||
	}
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,25 +1,4 @@
 | 
			
		||||
// gomuks - A terminal Matrix client written in Go.
 | 
			
		||||
// Copyright (C) 2020 Tulir Asokan
 | 
			
		||||
//
 | 
			
		||||
// This program is free software: you can redistribute it and/or modify
 | 
			
		||||
// it under the terms of the GNU Affero General Public License as published by
 | 
			
		||||
// the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
// (at your option) any later version.
 | 
			
		||||
//
 | 
			
		||||
// This program is distributed in the hope that it will be useful,
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
// GNU Affero General Public License for more details.
 | 
			
		||||
//
 | 
			
		||||
// You should have received a copy of the GNU Affero General Public License
 | 
			
		||||
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
package open
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os/exec"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Open(input string) error {
 | 
			
		||||
	return exec.Command("open", input).Start()
 | 
			
		||||
}
 | 
			
		||||
const Command = "open"
 | 
			
		||||
var Args []string
 | 
			
		||||
 
 | 
			
		||||
@@ -18,14 +18,10 @@ package open
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const FileProtocolHandler = "url.dll,FileProtocolHandler"
 | 
			
		||||
 | 
			
		||||
var RunDLL32 = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
 | 
			
		||||
 | 
			
		||||
func Open(input string) error {
 | 
			
		||||
	return exec.Command(RunDLL32, FileProtocolHandler, input).Start()
 | 
			
		||||
}
 | 
			
		||||
var Command = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
 | 
			
		||||
var Args = []string{FileProtocolHandler}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								lib/open/open_xdg.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/open/open_xdg.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
// +build !windows,!darwin
 | 
			
		||||
 | 
			
		||||
package open
 | 
			
		||||
 | 
			
		||||
const Command = "xdg-open"
 | 
			
		||||
var Args []string
 | 
			
		||||
		Reference in New Issue
	
	Block a user