Skip to content
This repository was archived by the owner on Feb 10, 2023. It is now read-only.

Commit f194020

Browse files
fix custom commands
1 parent 862bf92 commit f194020

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@ func main() {
197197
monitor = true
198198
}
199199
var stdoutIn io.ReadCloser
200+
url := getProperURL(context.EpID)
200201
//run every command
201202
for j := range com.Commands {
202203
if len(com.Commands[j]) > 0 {
203204
//replace placeholder with real URL
204-
for x, s := range com.Commands[j] {
205-
if s == "$url" {
206-
com.Commands[j][x] = getProperURL(context.EpID)
207-
}
205+
tmpCommand := make([]string, len(com.Commands[j]))
206+
copy(tmpCommand, com.Commands[j])
207+
for x, s := range tmpCommand {
208+
tmpCommand[x] = strings.Replace(s, "$url", url, -1)
208209
}
209210
//run command
210-
cmd := exec.Command(com.Commands[j][0], com.Commands[j][1:]...)
211+
cmd := exec.Command(tmpCommand[0], tmpCommand[1:]...)
211212
stdoutIn, _ = cmd.StdoutPipe()
212213
cmd.Start()
213214
scanner := bufio.NewScanner(stdoutIn)

0 commit comments

Comments
 (0)