fix!: make exec path in job add explicit in lua side

extended-job-api
TorchedSammy 2022-05-21 20:11:15 -04:00
parent f43ff7d03c
commit e50ee0b511
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 8 additions and 4 deletions

12
job.go
View File

@ -222,7 +222,7 @@ func (j *jobHandler) loader(rtm *rt.Runtime) *rt.Table {
"all": {j.luaAllJobs, 0, false}, "all": {j.luaAllJobs, 0, false},
"last": {j.luaLastJob, 0, false}, "last": {j.luaLastJob, 0, false},
"get": {j.luaGetJob, 1, false}, "get": {j.luaGetJob, 1, false},
"add": {j.luaAddJob, 2, false}, "add": {j.luaAddJob, 3, false},
"disown": {j.luaDisownJob, 1, false}, "disown": {j.luaDisownJob, 1, false},
} }
@ -253,7 +253,7 @@ func (j *jobHandler) luaGetJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
} }
func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.CheckNArgs(2); err != nil { if err := c.CheckNArgs(3); err != nil {
return nil, err return nil, err
} }
cmd, err := c.StringArg(0) cmd, err := c.StringArg(0)
@ -264,6 +264,10 @@ func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
execPath, err := c.StringArg(2)
if err != nil {
return nil, err
}
var args []string var args []string
util.ForEach(largs, func(k rt.Value, v rt.Value) { util.ForEach(largs, func(k rt.Value, v rt.Value) {
@ -271,8 +275,8 @@ func (j *jobHandler) luaAddJob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
args = append(args, v.AsString()) args = append(args, v.AsString())
} }
}) })
// TODO: change to lookpath for args[0]
jb := j.add(cmd, args, args[0]) jb := j.add(cmd, args, execPath)
return c.PushingNext1(t.Runtime, jb.lua()), nil return c.PushingNext1(t.Runtime, jb.lua()), nil
} }