Pass options to subshell when executing a ScriptFunc
This commit is contained in:
parent
61ba975e21
commit
b56641c659
|
@ -142,7 +142,7 @@ func (d *Decoder) DecodeVars(val any) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScriptFunc func(ctx context.Context, sir string, args ...string) error
|
type ScriptFunc func(ctx context.Context, opts ...interp.RunnerOption) error
|
||||||
|
|
||||||
// GetFunc returns a function corresponding to a bash function
|
// GetFunc returns a function corresponding to a bash function
|
||||||
// with the given name
|
// with the given name
|
||||||
|
@ -152,10 +152,11 @@ func (d *Decoder) GetFunc(name string) (ScriptFunc, bool) {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
return func(ctx context.Context, dir string, args ...string) error {
|
return func(ctx context.Context, opts ...interp.RunnerOption) error {
|
||||||
sub := d.runner.Subshell()
|
sub := d.runner.Subshell()
|
||||||
interp.Params(args...)(sub)
|
for _, opt := range opts {
|
||||||
interp.Dir(dir)(sub)
|
opt(sub)
|
||||||
|
}
|
||||||
return sub.Run(ctx, fn)
|
return sub.Run(ctx, fn)
|
||||||
}, true
|
}, true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue