fix(parser): use Fields instead of Split

This commit is contained in:
jguer 2020-10-27 13:59:00 +01:00 committed by J Guerreiro
parent 81b5feb68a
commit 55a6767b44
3 changed files with 15 additions and 8 deletions

View File

@ -37,7 +37,9 @@ func (r *OSRunner) Capture(cmd *exec.Cmd, timeout int64) (stdout, stderr string,
cmd.Stderr = &errbuf
err = cmd.Start()
if err != nil {
return "", "", err
stdout = strings.TrimSpace(outbuf.String())
stderr = strings.TrimSpace(errbuf.String())
return stdout, stderr, err
}
if timeout != 0 {
@ -54,12 +56,13 @@ func (r *OSRunner) Capture(cmd *exec.Cmd, timeout int64) (stdout, stderr string,
if timeout != 0 {
timer.Stop()
}
if err != nil {
return "", "", err
}
stdout = strings.TrimSpace(outbuf.String())
stderr = strings.TrimSpace(errbuf.String())
if err != nil {
return stdout, stderr, err
}
if timedOut {
err = fmt.Errorf("command timed out")
}

View File

@ -21,7 +21,9 @@ func (c *CmdBuilder) BuildGitCmd(dir string, extraArgs ...string) *exec.Cmd {
args = append(args, "-C", dir)
}
args = append(args, extraArgs...)
if len(extraArgs) > 0 {
args = append(args, extraArgs...)
}
cmd := exec.Command(c.GitBin, args...)
cmd.Env = append(os.Environ(), "GIT_TERMINAL_PROMPT=0")
@ -36,7 +38,9 @@ func (c *CmdBuilder) BuildMakepkgCmd(dir string, extraArgs ...string) *exec.Cmd
args = append(args, "--config", c.MakepkgConfPath)
}
args = append(args, extraArgs...)
if len(extraArgs) > 0 {
args = append(args, extraArgs...)
}
cmd := exec.Command(c.MakepkgBin, args...)
cmd.Dir = dir

View File

@ -817,8 +817,8 @@ func (a *Arguments) ParseCommandLine(config *Configuration) error {
}
a.extractYayOptions(config)
config.Runtime.CmdBuilder.MakepkgFlags = strings.Split(config.MFlags, " ")
config.Runtime.CmdBuilder.GitFlags = strings.Split(config.GitFlags, " ")
config.Runtime.CmdBuilder.MakepkgFlags = strings.Fields(config.MFlags)
config.Runtime.CmdBuilder.GitFlags = strings.Fields(config.GitFlags)
return nil
}