diff options
| author | matkuki <kukovecmatic@hotmail.com> | 2019-10-22 23:36:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-22 23:36:49 +0200 |
| commit | 36ef771ea82fe5c775100195d55e18e960fd5cc7 (patch) | |
| tree | 0dddba0f1233ad0733d6fb92454bb1228904fe7a | |
| parent | 35cd391ecd62b6c0c4e9d28ebde0af0d9f68e5e0 (diff) | |
| download | nimterop-36ef771ea82fe5c775100195d55e18e960fd5cc7.tar.gz nimterop-36ef771ea82fe5c775100195d55e18e960fd5cc7.zip | |
Updated to search for "cd x:"
Tested again with `libmodbus` and it works.
| -rw-r--r-- | nimterop/build.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/nimterop/build.nim b/nimterop/build.nim index c1eb7ee..b2fbc48 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -1,4 +1,4 @@ -import macros, osproc, sets, strformat, strutils, tables +import macros, osproc, sets, strformat, strutils, regex, tables import os except findExe, sleep @@ -29,13 +29,13 @@ proc execAction*(cmd: string, retry = 0, nostderr = false): string = ccmd = "" ret = 0 when defined(Windows): - 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}" + var + filteredCmd = cmd + matches: RegexMatch + if cmd.find(re"cd\s+(\D)\:", matches): + var driveLetter = cmd[matches.group(0)[0]] + filteredCmd = &"{driveLetter}: && {cmd}" + echo filteredCmd ccmd = "cmd /c " & filteredCmd elif defined(posix): ccmd = cmd |
