@@ -33,12 +33,13 @@ const SignalForwardingDelay = time.Second * 15
3333
3434// ShellOptions contains the configuration needed to run shell commands.
3535type ShellOptions struct {
36- Writers writer.Writers
37- EngineOptions * engine.EngineOptions
38- EngineConfig * engine.EngineConfig
39- Telemetry * telemetry.Options
40- Env map [string ]string
41- Exec vexec.Exec
36+ Writers writer.Writers
37+ EngineOptions * engine.EngineOptions
38+ EngineConfig * engine.EngineConfig
39+ Telemetry * telemetry.Options
40+ Env map [string ]string
41+ Exec vexec.Exec
42+
4243 RootWorkingDir string
4344 WorkingDir string
4445 TFPath string
@@ -153,8 +154,7 @@ func (o *ShellOptions) WithForwardTFStdout(f bool) *ShellOptions {
153154 return o
154155}
155156
156- // WithExec installs a vexec.Exec backend that replaces the default os/exec
157- // path used by RunCommandWithOutput. Pass nil to clear it. Intended for tests.
157+ // WithExec sets the vexec.Exec used by RunCommandWithOutput.
158158func (o * ShellOptions ) WithExec (e vexec.Exec ) * ShellOptions {
159159 o .Exec = e
160160
@@ -258,6 +258,10 @@ func RunCommandWithOutput(
258258 }
259259
260260 if runOpts .Exec != nil {
261+ if needsPTY {
262+ return errors .New ("shell: vexec backend does not support PTY mode" )
263+ }
264+
261265 injectedCmd := runOpts .Exec .Command (ctx , command , args ... )
262266 injectedCmd .SetDir (commandDir )
263267 injectedCmd .SetEnv (util .EnvSliceFromMap (runOpts .Env ))
@@ -305,6 +309,7 @@ func RunCommandWithOutput(
305309
306310// procExecError builds a ProcessExecutionError using the standard fields from ShellOptions.
307311// Pass nil for output when the failure occurred before any output was captured.
312+ // Caller guarantees a non-nil ShellOptions; the receiver is dereferenced unconditionally.
308313func (o * ShellOptions ) procExecError (err error , command , dir string , args []string , output * util.CmdOutput ) error {
309314 pe := util.ProcessExecutionError {
310315 Err : err ,
0 commit comments