File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,21 @@ package main
22
33import (
44 "os/exec"
5+ "path/filepath"
6+ "strings"
57 "syscall"
68)
79
810func Command (name string , arg ... string ) * exec.Cmd {
911 cmd := exec .Command (name , arg ... )
1012
11- // Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not
12- // other characters that need escaping such as `<` and `>`.
13- // This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313
14- cmd .SysProcAttr = & syscall.SysProcAttr {CmdLine : makeCmdLine (cmd .Args )}
13+ exeName := filepath .Base (strings .ToLower (name ))
14+ if exeName == "cmd" || strings .HasSuffix (exeName , ".bat" ) {
15+ // Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not
16+ // other characters that need escaping such as `<` and `>`.
17+ // This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313
18+ cmd .SysProcAttr = & syscall.SysProcAttr {CmdLine : makeCmdLine (cmd .Args )}
19+ }
1520
1621 return cmd
1722}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package osutils
33import (
44 "os"
55 "os/exec"
6+ "path/filepath"
67 "strings"
78 "syscall"
89
@@ -21,10 +22,13 @@ func init() {
2122func Command (name string , arg ... string ) * exec.Cmd {
2223 cmd := exec .Command (name , arg ... )
2324
24- // Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not
25- // other characters that need escaping such as `<` and `>`.
26- // This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313
27- cmd .SysProcAttr = & syscall.SysProcAttr {CmdLine : makeCmdLine (cmd .Args )}
25+ exeName := filepath .Base (strings .ToLower (name ))
26+ if exeName == "cmd" || strings .HasSuffix (exeName , ".bat" ) {
27+ // Go currently does not escape arguments properly on Windows, it account for spaces and tab characters, but not
28+ // other characters that need escaping such as `<` and `>`.
29+ // This can be dropped once we update to a Go version that fixes this bug: https://github.com/golang/go/issues/68313
30+ cmd .SysProcAttr = & syscall.SysProcAttr {CmdLine : makeCmdLine (cmd .Args )}
31+ }
2832
2933 return cmd
3034}
You can’t perform that action at this time.
0 commit comments