Skip to content

Commit dfecc34

Browse files
authoredFeb 2, 2020
Quote nim executable before executing. (nim-lang#13316) [backport]
In case nim executable is located in PATH containing spaces. fixes nim-lang#13311
1 parent d43e5be commit dfecc34

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
 

Diff for: ‎koch.nim

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ when false:
259259

260260
proc pdf(args="") =
261261
exec("$# cc -r tools/nimweb.nim $# --pdf web/website.ini --putenv:nimversion=$#" %
262-
[findNim(), args, VersionAsString], additionalPATH=findNim().splitFile.dir)
262+
[findNim().quoteShell(), args, VersionAsString], additionalPATH=findNim().splitFile.dir)
263263

264264
# -------------- boot ---------------------------------------------------------
265265

@@ -297,7 +297,7 @@ proc boot(args: string) =
297297
let smartNimcache = (if "release" in args or "danger" in args: "nimcache/r_" else: "nimcache/d_") &
298298
hostOS & "_" & hostCPU
299299

300-
let nimStart = findStartNim()
300+
let nimStart = findStartNim().quoteShell()
301301
for i in 0..2:
302302
let defaultCommand = if useCpp: "cpp" else: "c"
303303
let bootOptions = if args.len == 0 or args.startsWith("-"): defaultCommand else: ""
@@ -455,7 +455,7 @@ proc temp(args: string) =
455455
"threads" notin programArgs and
456456
"js" notin programArgs:
457457
bootArgs.add " -d:leanCompiler"
458-
let nimexec = findNim()
458+
let nimexec = findNim().quoteShell()
459459
exec(nimexec & " c -d:debug --debugger:native -d:nimBetterRun " & bootArgs & " " & (d / "compiler" / "nim"), 125)
460460
copyExe(output, finalDest)
461461
setCurrentDir(origDir)

Diff for: ‎tools/kochdocs.nim

+8-8
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ proc execCleanPath*(cmd: string,
7070

7171
proc nimexec*(cmd: string) =
7272
# Consider using `nimCompile` instead
73-
exec findNim() & " " & cmd
73+
exec findNim().quoteShell() & " " & cmd
7474

7575
proc nimCompile*(input: string, outputDir = "bin", mode = "c", options = "") =
7676
let output = outputDir / input.splitFile.name.exe
77-
let cmd = findNim() & " " & mode & " -o:" & output & " " & options & " " & input
77+
let cmd = findNim().quoteShell() & " " & mode & " -o:" & output & " " & options & " " & input
7878
exec cmd
7979

8080
proc nimCompileFold*(desc, input: string, outputDir = "bin", mode = "c", options = "") =
8181
let output = outputDir / input.splitFile.name.exe
82-
let cmd = findNim() & " " & mode & " -o:" & output & " " & options & " " & input
82+
let cmd = findNim().quoteShell() & " " & mode & " -o:" & output & " " & options & " " & input
8383
execFold(desc, cmd)
8484

8585
const
@@ -299,15 +299,15 @@ proc buildDocSamples(nimArgs, destPath: string) =
299299
##
300300
## TODO: consider integrating into the existing generic documentation builders
301301
## now that we have a single `doc` command.
302-
exec(findNim() & " doc $# -o:$# $#" %
302+
exec(findNim().quoteShell() & " doc $# -o:$# $#" %
303303
[nimArgs, destPath / "docgen_sample.html", "doc" / "docgen_sample.nim"])
304304

305305
proc buildDoc(nimArgs, destPath: string) =
306306
# call nim for the documentation:
307307
var
308308
commands = newSeq[string](rst2html.len + len(doc0) + len(doc) + withoutIndex.len)
309309
i = 0
310-
let nim = findNim()
310+
let nim = findNim().quoteShell()
311311
for d in items(rst2html):
312312
commands[i] = nim & " rst2html $# --git.url:$# -o:$# --index:on $#" %
313313
[nimArgs, gitUrl,
@@ -339,7 +339,7 @@ proc buildPdfDoc*(nimArgs, destPath: string) =
339339
else:
340340
const pdflatexcmd = "pdflatex -interaction=nonstopmode "
341341
for d in items(pdf):
342-
exec(findNim() & " rst2tex $# $#" % [nimArgs, d])
342+
exec(findNim().quoteShell() & " rst2tex $# $#" % [nimArgs, d])
343343
# call LaTeX twice to get cross references right:
344344
exec(pdflatexcmd & changeFileExt(d, "tex"))
345345
exec(pdflatexcmd & changeFileExt(d, "tex"))
@@ -356,9 +356,9 @@ proc buildPdfDoc*(nimArgs, destPath: string) =
356356
removeFile(changeFileExt(d, "tex"))
357357

358358
proc buildJS() =
359-
exec(findNim() & " js -d:release --out:$1 tools/nimblepkglist.nim" %
359+
exec(findNim().quoteShell() & " js -d:release --out:$1 tools/nimblepkglist.nim" %
360360
[webUploadOutput / "nimblepkglist.js"])
361-
exec(findNim() & " js " & (docHackDir / "dochack.nim"))
361+
exec(findNim().quoteShell() & " js " & (docHackDir / "dochack.nim"))
362362

363363
proc buildDocs*(args: string) =
364364
const

0 commit comments

Comments
 (0)
Please sign in to comment.