Open stoneface86 opened 2 years ago
Possible solution: escape spaces? Is that possible in Windows shell?
https://github.com/nim-lang/Nim/blob/devel/compiler/docgen.nim#L536 Issue with execShellCmd perhaps? I don't think this is expected behavior:
import std/os
# dummy.exe was compiled from an empty nim module
echo execShellCmd("\"folder with space\\dummy.exe\" bogus bogus")
echo execShellCmd("\"folder with space\\dummy.exe\" \"bogus bogus\"")
Output:
0
'folder' is not recognized as an internal or external command,
operable program or batch file.
1
The second command runs fine when running it in command prompt.
This hack works:
echo execShellCmd("if 1==1 \"folder with space\\dummy.exe\" \"bogus bogus\"")
https://stackoverflow.com/questions/4244095/system-function-seems-to-ignore-quote-marks
Possible solution: escape spaces? Is that possible in Windows shell?
Command prompt supports escaping a space by using a space preceded by a caret, ie ^
but this rarely works apparently
In Powershell you can use a grave followed by a space.
Tried both of these and they didn't work. execShellCmd
calls the c standard library function system
which on windows uses command prompt. Command prompt likes to remove quotations if you have multiple of them for some odd reason. From what I've researched, it seems like using CreateProcess
is the preferred approach.
So a possible solution would be to use CreateProcess
on windows for os.execShellCmd
instead of system
. Or to prepend if 1==1
to the command passed to system
Running
nim doc
when the path of the nim compiler has spaces in it fails to build the runnableExamplesExample
Have nim installed in a path with spaces in it, for this example I'm using
C:\Users\Bren (Work)\.choosenim\toolchains\nim-1.6.6\bin\nim.exe
Save this as test.nim:
Then run:
Current Output
Expected Output
Same as current but without the "[runnableExamples] failed: ..."
Possible Solution
Unsure, might be a platform-specific issue with
os.execShellCmd
Additional Information
Occurs on both stable and devel, Windows 10 64-bit. Did not test other platforms.
Forum post where I first encountered the issue - https://forum.nim-lang.org/t/9161