Skip to content

Commit 700a888

Browse files
committed
move TellCommandNotToSpawnShell to tools package
1 parent 62fa42b commit 700a888

7 files changed

+25
-14
lines changed

programmer.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"strings"
1818
"time"
1919

20+
"github.com/arduino/arduino-create-agent/tools"
21+
2022
log "github.com/Sirupsen/logrus"
2123
"github.com/facchinm/go-serial"
2224
"github.com/mattn/go-shellwords"
@@ -305,7 +307,7 @@ func spHandlerProgram(flasher string, cmdString []string) error {
305307

306308
oscmd = exec.Command(flasher, cmdString...)
307309

308-
tellCommandNotToSpawnShell(oscmd)
310+
tools.TellCommandNotToSpawnShell(oscmd)
309311

310312
stdout, err := oscmd.StdoutPipe()
311313
if err != nil {

seriallist_darwin.go

-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,3 @@ func associateVidPidWithPort(ports []OsSerialPort) []OsSerialPort {
6464
}
6565
return ports
6666
}
67-
68-
func tellCommandNotToSpawnShell(_ *exec.Cmd) {
69-
}

seriallist_linux.go

-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,3 @@ func associateVidPidWithPort(ports []OsSerialPort) []OsSerialPort {
3434
}
3535
return ports
3636
}
37-
38-
func tellCommandNotToSpawnShell(_ *exec.Cmd) {
39-
}

seriallist_windows.go

-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ package main
22

33
import (
44
"os"
5-
"os/exec"
65
"regexp"
76
"strings"
87
"sync"
9-
"syscall"
108

119
log "github.com/Sirupsen/logrus"
1210
"github.com/mattn/go-ole"
@@ -227,7 +225,3 @@ func convertByteArrayToUint16Array(b []byte, mylen uint32) []uint16 {
227225
}
228226
return ret
229227
}
230-
231-
func tellCommandNotToSpawnShell(oscmd *exec.Cmd) {
232-
oscmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
233-
}

tools/hidefile_darwin.go

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package tools
22

3+
import (
4+
"os/exec"
5+
)
6+
37
func hideFile(path string) {
48

59
}
10+
11+
func TellCommandNotToSpawnShell(_ *exec.Cmd) {
12+
}

tools/hidefile_linux.go

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package tools
22

3+
import (
4+
"os/exec"
5+
)
6+
37
func hideFile(path string) {
48

59
}
10+
11+
func TellCommandNotToSpawnShell(_ *exec.Cmd) {
12+
}

tools/hidefile_windows.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package tools
22

3-
import "syscall"
3+
import (
4+
"os/exec"
5+
"syscall"
6+
)
47

58
func hideFile(path string) {
69
cpath, cpathErr := syscall.UTF16PtrFromString(path)
710
if cpathErr != nil {
811
}
912
syscall.SetFileAttributes(cpath, syscall.FILE_ATTRIBUTE_HIDDEN)
1013
}
14+
15+
func TellCommandNotToSpawnShell(oscmd *exec.Cmd) {
16+
oscmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
17+
}

0 commit comments

Comments
 (0)