diff options
| author | matkuki <kukovecmatic@hotmail.com> | 2019-10-21 21:18:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-21 21:18:01 +0200 |
| commit | 35cd391ecd62b6c0c4e9d28ebde0af0d9f68e5e0 (patch) | |
| tree | 883fd5fbaf3e08a2bb4accc1669b7e917f7e3d5a | |
| parent | d3b558b291be1d6dd0885de2ef154b70ed2cfbac (diff) | |
| download | nimterop-35cd391ecd62b6c0c4e9d28ebde0af0d9f68e5e0.tar.gz nimterop-35cd391ecd62b6c0c4e9d28ebde0af0d9f68e5e0.zip | |
Fix for Windows drive changes
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.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nimterop/build.nim b/nimterop/build.nim index f96593e..c1eb7ee 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -29,7 +29,14 @@ proc execAction*(cmd: string, retry = 0, nostderr = false): string = ccmd = "" ret = 0 when defined(Windows): - ccmd = "cmd /c " & cmd + var filteredCmd = cmd + if cmd.startsWith("cd"): + var + colonIndex = cmd.find(":") + driveLetter = cmd.substr(colonIndex-1, colonIndex) + if driveLetter[0].isAlphaAscii() and driveLetter[1] == ':': + filteredCmd = &"{driveLetter} && {cmd}" + ccmd = "cmd /c " & filteredCmd elif defined(posix): ccmd = cmd else: |
