Skip to content

Commit

Permalink
trim execute
Browse files Browse the repository at this point in the history
  • Loading branch information
CMA2401PT committed Jul 26, 2024
1 parent 58f7344 commit 45680d7
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions oslib.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,25 @@ func osDiffTime(L *LState) int {
}

func osExecute(L *LState) int {
var procAttr os.ProcAttr
procAttr.Files = []*os.File{os.Stdin, os.Stdout, os.Stderr}
cmd, args := popenArgs(L.CheckString(1))
args = append([]string{cmd}, args...)
process, err := os.StartProcess(cmd, args, &procAttr)
if err != nil {
L.Push(LNumber(1))
return 1
}

ps, err := process.Wait()
if err != nil || !ps.Success() {
L.Push(LNumber(1))
return 1
}
L.Push(LNumber(0))
return 1
panic("execute is not supported")
return 0
// var procAttr os.ProcAttr
// procAttr.Files = []*os.File{os.Stdin, os.Stdout, os.Stderr}
// cmd, args := popenArgs(L.CheckString(1))
// args = append([]string{cmd}, args...)
// process, err := os.StartProcess(cmd, args, &procAttr)
// if err != nil {
// L.Push(LNumber(1))
// return 1
// }

// ps, err := process.Wait()
// if err != nil || !ps.Success() {
// L.Push(LNumber(1))
// return 1
// }
// L.Push(LNumber(0))
// return 1
}

func osExit(L *LState) int {
Expand Down

0 comments on commit 45680d7

Please sign in to comment.