aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgenotrance <dev@genotrance.com>2019-10-23 10:52:59 -0500
committerGitHub <noreply@github.com>2019-10-23 10:52:59 -0500
commit3c960c140c1237231c99cd34896752abc35fb371 (patch)
tree5728d1be6cce30f568111d5491d9951c6c6d9a7a
parent37f5faa43d446a415e8934cc1a713bb7f5c5564f (diff)
parent3765862b6ee94ca661ca24a636af950bfc37d9c4 (diff)
downloadnimterop-3c960c140c1237231c99cd34896752abc35fb371.tar.gz
nimterop-3c960c140c1237231c99cd34896752abc35fb371.zip
Merge pull request #145 from matkuki/patch-1
This adds a drive change command to every Windows `execAction` call that starts with the `cd` command. Tested with the `libmodbus` C library (https://github.com/stephane/libmodbus).
-rw-r--r--nimterop/build.nim11
1 files changed, 10 insertions, 1 deletions
diff --git a/nimterop/build.nim b/nimterop/build.nim
index f96593e..cbf9b25 100644
--- a/nimterop/build.nim
+++ b/nimterop/build.nim
@@ -29,7 +29,16 @@ proc execAction*(cmd: string, retry = 0, nostderr = false): string =
ccmd = ""
ret = 0
when defined(Windows):
- ccmd = "cmd /c " & cmd
+ var filteredCmd = cmd
+ if cmd.toLower().startsWith("cd"):
+ var
+ colonIndex = cmd.find(":")
+ driveLetter = cmd.substr(colonIndex-1, colonIndex)
+ if (driveLetter[0].isAlphaAscii() and
+ driveLetter[1] == ':' and
+ colonIndex == 4):
+ filteredCmd = &"{driveLetter} && {cmd}"
+ ccmd = "cmd /c " & filteredCmd
elif defined(posix):
ccmd = cmd
else: