Pass options to subshell when executing a ScriptFunc

This commit is contained in:
Elara 2022-10-02 19:59:10 -07:00
parent 61ba975e21
commit b56641c659
1 changed files with 5 additions and 4 deletions

View File

@ -142,7 +142,7 @@ func (d *Decoder) DecodeVars(val any) error {
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
// with the given name
@ -152,10 +152,11 @@ func (d *Decoder) GetFunc(name string) (ScriptFunc, bool) {
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()
interp.Params(args...)(sub)
interp.Dir(dir)(sub)
for _, opt := range opts {
opt(sub)
}
return sub.Run(ctx, fn)
}, true
}