@@ -100,7 +100,7 @@ func (s *Shell) Exec(ctx context.Context, command string) (string, string, error
s.mu.Lock()
defer s.mu.Unlock()
- return s.execPOSIX(ctx, command)
+ return s.exec(ctx, command)
}
// GetWorkingDir returns the current working directory
@@ -228,8 +228,8 @@ func (s *Shell) blockHandler() func(next interp.ExecHandlerFunc) interp.ExecHand
}
}
-// execPOSIX executes commands using POSIX shell emulation (cross-platform)
-func (s *Shell) execPOSIX(ctx context.Context, command string) (string, string, error) {
+// exec executes commands using a cross-platform shell interpreter.
+func (s *Shell) exec(ctx context.Context, command string) (string, string, error) {
line, err := syntax.NewParser().Parse(strings.NewReader(command), "")
if err != nil {
return "", "", fmt.Errorf("could not parse command: %w", err)
@@ -249,11 +249,10 @@ func (s *Shell) execPOSIX(ctx context.Context, command string) (string, string,
err = runner.Run(ctx, line)
s.cwd = runner.Dir
- s.env = []string{}
for name, vr := range runner.Vars {
s.env = append(s.env, fmt.Sprintf("%s=%s", name, vr.Str))
}
- s.logger.InfoPersist("POSIX command finished", "command", command, "err", err)
+ s.logger.InfoPersist("command finished", "command", command, "err", err)
return stdout.String(), stderr.String(), err
}