[PATCH] build: quote environment variables that may have spaces on Windows

9 views
Skip to first unread message

Matt Harbison

unread,
Apr 25, 2025, 10:26:28 PMApr 25
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1745603944 14400
# Fri Apr 25 13:59:04 2025 -0400
# Branch stable
# Node ID 7041279d545583ec40e3e5b5cfb8ad6ab7429d74
# Parent 2e46a40ecc9cc87d4eff64538de345caa0f9772f
build: quote environment variables that may have spaces on Windows

Builds have been complaining for several years now that 'Files' is not
recognized as an internal or external command, and it's because `%hhc_compiler%`
was set to its path in `%ProgramFiles(x86)%` (which has spaces), and skewed the
meaning of the `if not exist` conditional. That caused the variable to be set
to `hhc.exe` unconditionally, which still worked because it also happened to be
on PATH.

The trailing '.' was a way to keep the syntax valid if the variable evaluated
to an empty string. But, we're better off without it, now that there's quoting:

C:\>if not exist "C:\Program Files (x86)\HTML Help Workshop\hhc.exe". ( echo missing )

C:\>if not exist "". ( echo missing )

C:\>if not exist "" ( echo missing )
missing

diff --git a/doc/Build.bat b/doc/Build.bat
--- a/doc/Build.bat
+++ b/doc/Build.bat
@@ -1,10 +1,10 @@
@echo off
setlocal

-if not exist %hhc_compiler%. (
+if not exist "%hhc_compiler%" (
set hhc_compiler=hhc.exe
)
-if not exist %qcollectiongenerator%. (
+if not exist "%qcollectiongenerator%" (
set qcollectiongenerator=qcollectiongenerator.exe
)
set PDFLATEX=PdfLatex
@@ -65,7 +65,7 @@

if "%1" == "chm" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %OUTPUTDIR%/chm
- %hhc_compiler% %OUTPUTDIR%/chm/TortoiseHg.hhp
+ "%hhc_compiler%" %OUTPUTDIR%/chm/TortoiseHg.hhp
echo.
echo.Build finished. The CHM file is in %OUTPUTDIR%/chm.
goto end
@@ -84,7 +84,7 @@

if "%1" == "qhc" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %OUTPUTDIR%/qthelp
- %qcollectiongenerator% %OUTPUTDIR%/qthelp/TortoiseHg.qhcp
+ "%qcollectiongenerator%" %OUTPUTDIR%/qthelp/TortoiseHg.qhcp
echo.
echo.Build finished. The QHC file is in %OUTPUTDIR%/qthelp.
goto end

Matt Harbison

unread,
Apr 25, 2025, 10:31:35 PMApr 25
to TortoiseHg Developers
On Friday, April 25, 2025 at 10:26:28 PM UTC-4 Matt Harbison wrote:
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1745603944 14400
# Fri Apr 25 13:59:04 2025 -0400
# Branch stable
# Node ID 7041279d545583ec40e3e5b5cfb8ad6ab7429d74
# Parent 2e46a40ecc9cc87d4eff64538de345caa0f9772f
build: quote environment variables that may have spaces on Windows

I guess we should cut a release.  I'm fine with skipping the RC and going to 7.0.1 to match the security update in hg, since I've been running the latest thg and hg 7.0 on Windows for the last month without a problem. 

Yuya Nishihara

unread,
Apr 25, 2025, 10:40:03 PMApr 25
to Matt Harbison, thg...@googlegroups.com
On Fri, 25 Apr 2025 22:25:44 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1745603944 14400
> # Fri Apr 25 13:59:04 2025 -0400
> # Branch stable
> # Node ID 7041279d545583ec40e3e5b5cfb8ad6ab7429d74
> # Parent 2e46a40ecc9cc87d4eff64538de345caa0f9772f
> build: quote environment variables that may have spaces on Windows

Thanks. Queued and tagged 7.0.1.
Reply all
Reply to author
Forward
0 new messages