Skip to content

Commit 6096d09

Browse files
committed
Also address .cmd files
1 parent e5bcd1f commit 6096d09

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cmd/state-exec/cmd_windows.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ import (
55
"path/filepath"
66
"strings"
77
"syscall"
8+
9+
"github.com/ActiveState/cli/cmd/state-exec/internal/logr"
810
)
911

1012
func Command(name string, arg ...string) *exec.Cmd {
1113
cmd := exec.Command(name, arg...)
1214

1315
exeName := filepath.Base(strings.ToLower(name))
14-
if exeName == "cmd" || strings.HasSuffix(exeName, ".bat") {
16+
if exeName == "cmd" || strings.HasSuffix(exeName, ".bat") || strings.HasSuffix(exeName, ".cmd") {
1517
// Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not
1618
// other characters that need escaping such as `<` and `>`.
1719
// This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313
1820
cmd.SysProcAttr = &syscall.SysProcAttr{CmdLine: makeCmdLine(cmd.Args)}
21+
logr.Debug("processed command line: %s", cmd.SysProcAttr.CmdLine)
1922
}
2023

2124
return cmd

internal/osutils/exeutils_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func Command(name string, arg ...string) *exec.Cmd {
2323
cmd := exec.Command(name, arg...)
2424

2525
exeName := filepath.Base(strings.ToLower(name))
26-
if exeName == "cmd" || strings.HasSuffix(exeName, ".bat") {
26+
if exeName == "cmd" || strings.HasSuffix(exeName, ".bat") || strings.HasSuffix(exeName, ".cmd") {
2727
// Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not
2828
// other characters that need escaping such as `<` and `>`.
2929
// This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313

0 commit comments

Comments
 (0)