From b56641c659b4269189614f0a6b597e7ae1a0f966 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sun, 2 Oct 2022 19:59:10 -0700 Subject: [PATCH] Pass options to subshell when executing a ScriptFunc --- internal/shutils/decoder/decoder.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/shutils/decoder/decoder.go b/internal/shutils/decoder/decoder.go index 80be4be..63da392 100644 --- a/internal/shutils/decoder/decoder.go +++ b/internal/shutils/decoder/decoder.go @@ -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 }