diff options
| author | Timothee Cour <timothee.cour2@gmail.com> | 2019-02-08 13:59:41 -0800 |
|---|---|---|
| committer | genotrance <dev@genotrance.com> | 2019-02-08 15:59:41 -0600 |
| commit | 52264204749a2159153113b4ffb6545d2eccc2e4 (patch) | |
| tree | 7c81a7d1bab43b7701a5318753af73c9189a7e8d | |
| parent | 0ef310b7d9a3bf02b6caf54ba20982640e48156a (diff) | |
| download | nimterop-52264204749a2159153113b4ffb6545d2eccc2e4.tar.gz nimterop-52264204749a2159153113b4ffb6545d2eccc2e4.zip | |
execAction: quoting was not robust (in case cmd had quotes) and bash -c was redundant on posix (#117)
| -rw-r--r-- | nimterop/git.nim | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/nimterop/git.nim b/nimterop/git.nim index 86a042e..1d28179 100644 --- a/nimterop/git.nim +++ b/nimterop/git.nim @@ -8,18 +8,18 @@ proc execAction*(cmd: string, nostderr=false): string = ret = 0 when defined(Windows): ccmd = "cmd /c " & cmd - when defined(Linux) or defined(MacOSX): - ccmd = "bash -c \"" & cmd & "\"" + elif defined(posix): + ccmd = cmd + else: + doAssert false when nimvm: (result, ret) = gorgeEx(ccmd) else: - if nostderr: - (result, ret) = execCmdEx(ccmd, {poUsePath}) - else: - (result, ret) = execCmdEx(ccmd) + let opt = if nostderr: {poUsePath} else: {poStdErrToStdOut, poUsePath} + (result, ret) = execCmdEx(ccmd, opt) if ret != 0: - let msg = "Command failed: " & $ret & "\nccmd: " & ccmd & "\nresult:\n" & result + let msg = "Command failed: " & $(ret, nostderr) & "\nccmd: " & ccmd & "\nresult:\n" & result doAssert false, msg proc mkDir*(dir: string) = |
