From 1e65be7d1ad3f6adc224cf8bbcf3381236640f12 Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Wed, 9 Oct 2019 18:40:38 -0700 Subject: [PATCH] ICU-20858 Fix Windows data build failure with long paths --- .../icutools/databuilder/renderers/common_exec.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/icu4c/source/python/icutools/databuilder/renderers/common_exec.py b/icu4c/source/python/icutools/databuilder/renderers/common_exec.py index 838b121afe5..3623441555d 100644 --- a/icu4c/source/python/icutools/databuilder/renderers/common_exec.py +++ b/icu4c/source/python/icutools/databuilder/renderers/common_exec.py @@ -120,12 +120,15 @@ def run_shell_command(command_line, platform, verbose): # If the command line length on Windows exceeds the absolute maximum that CMD supports (8191), then # we temporarily switch over to use PowerShell for the command, and then switch back to CMD. # We don't want to use PowerShell for everything though, as it tends to be slower. - if (platform == "windows") and (len(command_line) > 8190): - if verbose: - print("Command length exceeds the max length for CMD on Windows, using PowerShell instead.") + if (platform == "windows"): previous_comspec = os.environ["COMSPEC"] - os.environ["COMSPEC"] = 'powershell' - changed_windows_comspec = True + # Add 7 to the length for the argument /c with quotes. + # For example: C:\WINDOWS\system32\cmd.exe /c "" + if ((len(previous_comspec) + len(command_line) + 7) > 8190): + if verbose: + print("Command length exceeds the max length for CMD on Windows, using PowerShell instead.") + os.environ["COMSPEC"] = 'powershell' + changed_windows_comspec = True if verbose: print("Running: %s" % command_line) returncode = subprocess.call( -- 2.40.0