Skip to content

Commit

Permalink
Fix for #7
Browse files Browse the repository at this point in the history
Multiple arguments are not properly passed to command
  • Loading branch information
christiangalsterer committed Feb 20, 2017
1 parent c1f799e commit 15be5ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ This will fetch and create all images required for the build process. The comple

# Releases

3.0.1 (2017-02-21) [Download](https://github.com/christiangalsterer/execbeat/releases/tag/3.0.1)

Bugfix release containing the following changes:
* [Multiple arguments are not properly passed](https://github.com/christiangalsterer/execbeat/issues/7)

3.0.0 (2017-02-19) [Download](https://github.com/christiangalsterer/execbeat/releases/tag/3.0.0)

Feature and bugfix release containing the following **breaking** changes:
Expand Down
12 changes: 9 additions & 3 deletions beater/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,26 @@ func (e *Executor) Run() {

func (e *Executor) runOneTime() error {
var cmd *exec.Cmd
var cmdArgs []string
var err error
var stdout bytes.Buffer
var stderr bytes.Buffer

cmdName := strings.TrimSpace(e.config.Command)
cmdArgs := strings.TrimSpace(e.config.Args)

args := strings.TrimSpace(e.config.Args)
if len(args) > 0 {
cmdArgs = strings.Split(args, " ")
}

// execute command
logp.Debug("Execbeat", "Executing command: [%v] with args [%w]", cmdName, cmdArgs)
now := time.Now()

if len(cmdArgs) > 0 {
cmd = exec.Command(cmdName, cmdArgs)
logp.Debug("Execbeat", "Executing command: [%v] with args [%w]", cmdName, cmdArgs)
cmd = exec.Command(cmdName, cmdArgs...)
} else {
logp.Debug("Execbeat", "Executing command: [%v]", cmdName)
cmd = exec.Command(cmdName)
}
cmd.Stdout = &stdout
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
)

var version = "3.0.0"
var version = "3.0.1-SNAPSHOT"
var name = "execbeat"

func main() {
Expand Down
2 changes: 2 additions & 0 deletions tests/files/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo $1 $2

0 comments on commit 15be5ec

Please sign in to comment.