From 4353a8e605b4d894dd6c609d7d8ded6993242aa6 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 21 Feb 2024 17:18:30 +0100 Subject: [PATCH] CMake: Fix passing -DFOO=0 to configure.bat Add a space before the redirection operator, so that the '0' in '-DFOO=0' after '%*' expansion, does not get squished with the '<', effectively redirecting from '0>' instead of stdout. As a drive-by, also add a comment why we need the '.'. Fixes: QTBUG-122622 Change-Id: I74ea3a1fe751cc1f2ad216b309f6b24d6d5f6b7f Reviewed-by: Joerg Bornemann Reviewed-by: Alexey Edelev (cherry picked from commit 0165a91bff80722d2384914dd40ca65a20fc1a47) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 3d18b218ddda73ad79703026b38b4b9829cc6805) (cherry picked from commit 5e41dde4cde2d880ef6321ab0f8e7ad5fe398130) --- configure.bat | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.bat b/configure.bat index 32fcdd86264..7e459317511 100644 --- a/configure.bat +++ b/configure.bat @@ -83,7 +83,12 @@ set REDO_FILE_PATH=%TOPQTDIR%\config.redo.last set REDO_TMP_FILE_PATH=%TOPQTDIR%\config.redo.in set FRESH_REQUESTED_ARG= if not defined redoing ( - echo.%*>"%OPT_TMP_FILE_PATH%" + :: The '.' in 'echo.%*' ensures we don't print "echo is off" when no arguments are passed + :: https://devblogs.microsoft.com/oldnewthing/20170802-00/?p=96735 + :: The space before the '>' makes sure that when we have a digit at the end of the args, we + :: don't accidentally concatenate it with the '>' resulting in '0>' or '2>' which redirects + :: into the file from a stream different than stdout, leading to broken or empty content. + echo.%* >"%OPT_TMP_FILE_PATH%" cmake -DIN_FILE="%OPT_TMP_FILE_PATH%" -DOUT_FILE="%OPT_FILE_PATH%" -DIGNORE_ARGS=-top-level -P "%QTSRC%\cmake\QtWriteArgsFile.cmake" ) else (