mirror of https://github.com/Hilbis/Hilbish
fix: add substitute for exec syscall on windows
parent
c175bb4d8a
commit
e8d0ea12cc
29
api.go
29
api.go
|
@ -229,18 +229,27 @@ func appendPath(dir string) {
|
||||||
func hlexec(L *lua.LState) int {
|
func hlexec(L *lua.LState) int {
|
||||||
cmd := L.CheckString(1)
|
cmd := L.CheckString(1)
|
||||||
cmdArgs, _ := splitInput(cmd)
|
cmdArgs, _ := splitInput(cmd)
|
||||||
cmdPath, err := exec.LookPath(cmdArgs[0])
|
if runtime.GOOS != "windows" {
|
||||||
if err != nil {
|
cmdPath, err := exec.LookPath(cmdArgs[0])
|
||||||
fmt.Println(err)
|
if err != nil {
|
||||||
// if we get here, cmdPath will be nothing
|
fmt.Println(err)
|
||||||
// therefore nothing will run
|
// if we get here, cmdPath will be nothing
|
||||||
|
// therefore nothing will run
|
||||||
|
}
|
||||||
|
|
||||||
|
// syscall.Exec requires an absolute path to a binary
|
||||||
|
// path, args, string slice of environments
|
||||||
|
syscall.Exec(cmdPath, cmdArgs, os.Environ())
|
||||||
|
} else {
|
||||||
|
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
cmd.Stdin = os.Stdin
|
||||||
|
cmd.Run()
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// syscall.Exec requires an absolute path to a binary
|
return 0
|
||||||
// path, args, string slice of environments
|
|
||||||
// TODO: alternative for windows
|
|
||||||
syscall.Exec(cmdPath, cmdArgs, os.Environ())
|
|
||||||
return 0 // random thought: does this ever return?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// goro(fn)
|
// goro(fn)
|
||||||
|
|
Loading…
Reference in New Issue