Skip to content

Commit b9e41f8

Browse files
committed
refactor(shell): some small code adjustments
1 parent 569044c commit b9e41f8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

internal/shell/shell.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (s *Shell) Exec(ctx context.Context, command string) (string, string, error
100100
s.mu.Lock()
101101
defer s.mu.Unlock()
102102

103-
return s.execPOSIX(ctx, command)
103+
return s.exec(ctx, command)
104104
}
105105

106106
// GetWorkingDir returns the current working directory
@@ -228,8 +228,8 @@ func (s *Shell) blockHandler() func(next interp.ExecHandlerFunc) interp.ExecHand
228228
}
229229
}
230230

231-
// execPOSIX executes commands using POSIX shell emulation (cross-platform)
232-
func (s *Shell) execPOSIX(ctx context.Context, command string) (string, string, error) {
231+
// exec executes commands using a cross-platform shell interpreter.
232+
func (s *Shell) exec(ctx context.Context, command string) (string, string, error) {
233233
line, err := syntax.NewParser().Parse(strings.NewReader(command), "")
234234
if err != nil {
235235
return "", "", fmt.Errorf("could not parse command: %w", err)
@@ -249,11 +249,10 @@ func (s *Shell) execPOSIX(ctx context.Context, command string) (string, string,
249249

250250
err = runner.Run(ctx, line)
251251
s.cwd = runner.Dir
252-
s.env = []string{}
253252
for name, vr := range runner.Vars {
254253
s.env = append(s.env, fmt.Sprintf("%s=%s", name, vr.Str))
255254
}
256-
s.logger.InfoPersist("POSIX command finished", "command", command, "err", err)
255+
s.logger.InfoPersist("command finished", "command", command, "err", err)
257256
return stdout.String(), stderr.String(), err
258257
}
259258

0 commit comments

Comments
 (0)