Skip to content

Commit c54e5e7

Browse files
committed
Revert "Use powershell scripts instead of batch scripts for state exec."
This reverts commit b5ea2a0.
1 parent 7474d49 commit c54e5e7

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

internal/runners/exec/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ func (s *Exec) Run(params *Params, args ...string) (rerr error) {
188188
lang := language.Bash
189189
scriptArgs := fmt.Sprintf(`%q "$@"`, exeTarget)
190190
if strings.Contains(s.subshell.Binary(), "cmd") {
191-
lang = language.PowerShell
192-
scriptArgs = fmt.Sprintf("& %q @args\nexit $LASTEXITCODE", exeTarget)
191+
lang = language.Batch
192+
scriptArgs = fmt.Sprintf("@ECHO OFF\n%q %%*", exeTarget)
193193
}
194194

195195
sf, err := scriptfile.New(lang, "state-exec", scriptArgs)

internal/subshell/sscommon/sscommon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func runWithCmd(env []string, name string, args ...string) error {
127127
case ".bat":
128128
// No action required
129129
case ".ps1":
130-
args = append([]string{"-executionpolicy", "bypass", "-file", name}, args...)
130+
args = append([]string{"-file", name}, args...)
131131
name = "powershell"
132132
case ".sh":
133133
bashPath, err := osutils.BashifyPath(name)

test/integration/exec_int_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -197,28 +197,6 @@ func (suite *ExecIntegrationTestSuite) TestExecWithPath() {
197197

198198
}
199199

200-
func (suite *ExecIntegrationTestSuite) TestExecPerlArgs() {
201-
suite.OnlyRunForTags(tagsuite.Exec)
202-
ts := e2e.New(suite.T(), false)
203-
defer ts.Close()
204-
205-
cp := ts.Spawn("checkout", "ActiveState-CLI/Perl-5.32", ".")
206-
cp.Expect("Skipping runtime setup")
207-
cp.Expect("Checked out")
208-
cp.ExpectExitCode(0)
209-
210-
suite.NoError(fileutils.WriteFile(filepath.Join(ts.Dirs.Work, "testargs.pl"), []byte(`
211-
printf "Argument: '%s'.\n", $ARGV[0];
212-
`)))
213-
214-
cp = ts.SpawnWithOpts(
215-
e2e.OptArgs("exec", "perl", "testargs.pl", "<3"),
216-
e2e.OptAppendEnv(constants.DisableRuntime+"=false"),
217-
)
218-
cp.Expect("Argument: '<3'", e2e.RuntimeSourcingTimeoutOpt)
219-
cp.ExpectExitCode(0)
220-
}
221-
222200
func TestExecIntegrationTestSuite(t *testing.T) {
223201
suite.Run(t, new(ExecIntegrationTestSuite))
224202
}

0 commit comments

Comments
 (0)