Updated to search for "cd x:"

Tested again with `libmodbus` and it works.
This commit is contained in:
matkuki 2019-10-22 23:36:49 +02:00 • committed by GitHub
commit 36ef771ea8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
import macros, osproc, sets, strformat, strutils, tables import macros, osproc, sets, strformat, strutils, regex, tables
import os except findExe, sleep import os except findExe, sleep
@ -29,13 +29,13 @@ proc execAction*(cmd: string, retry = 0, nostderr = false): string =
ccmd = "" ccmd = ""
ret = 0 ret = 0
when defined(Windows): when defined(Windows):
var filteredCmd = cmd
if cmd.startsWith("cd"):
var var
colonIndex = cmd.find(":") filteredCmd = cmd
driveLetter = cmd.substr(colonIndex-1, colonIndex) matches: RegexMatch
if driveLetter[0].isAlphaAscii() and driveLetter[1] == ':': if cmd.find(re"cd\s+(\D)\:", matches):
filteredCmd = &"{driveLetter} && {cmd}" var driveLetter = cmd[matches.group(0)[0]]
filteredCmd = &"{driveLetter}: && {cmd}"
echo filteredCmd
ccmd = "cmd /c " & filteredCmd ccmd = "cmd /c " & filteredCmd
elif defined(posix): elif defined(posix):
ccmd = cmd ccmd = cmd