From: Magnus Jacobsson Date: Sun, 23 Aug 2020 08:25:50 +0000 (+0200) Subject: Make parsing of vcvarsall.bat output more robust X-Git-Tag: 2.46.0~20^2^2~114^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c84c75542a61b0cf1aed441129a91e0ebc7ce8f0;p=graphviz Make parsing of vcvarsall.bat output more robust Only consider variable names with alpanumeric characters, underscore and parentheses. This avoids most problems when parsing output containing multi-line variable values with arbitrary text. In GitLab CI, one of the environment variables is CI_COMMIT_MESSAGE. In the commit immediately following this commit there is an URL containing an equal sign that caused the error below: Set-Content : An object at the specified path env:\https://docs.microsoft.com/en-us/visualstudio/ide/how-to-configure-projects-to-target-platforms?view does not exist, or has been filtered by the -Include or -Exclude parameter. At line:3 char:5 + Set-Content "env:\$($matches[1])" $matches[2]; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (System.String[]:String[]) [Set-Content], Exception + FullyQualifiedErrorId : ItemNotFound,Microsoft.PowerShell.Commands.SetContentCommand --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd3b345bb..998390b5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -118,7 +118,7 @@ portable-source: - cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat`" $TARGET_ARCH && set > %temp%\vcvars.txt"; - >- Get-Content "$env:temp\vcvars.txt" | Foreach-Object { - if ($_ -match "^(.*?)=(.*)$") { + if ($_ -match "^([A-Za-z0-9_()]*)=(.*)$") { Set-Content "env:\$($matches[1])" $matches[2]; } }