From: Matthew Fernandez Date: Thu, 13 May 2021 01:14:17 +0000 (-0700) Subject: replace use of grep in Windows build utility setup with Select-String X-Git-Tag: 2.47.2~4^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2629780172903ce08b96b0787b8c675d4c9a6fe8;p=graphviz replace use of grep in Windows build utility setup with Select-String This is a built-in function in PowerShell with equivalent functionality for this purpose. This change is a step towards removing grep as a build dependency on Windows. Related to #2069. --- diff --git a/windows/bin/setup-build-utilities.ps1 b/windows/bin/setup-build-utilities.ps1 index cf03df3bb..14b99039b 100644 --- a/windows/bin/setup-build-utilities.ps1 +++ b/windows/bin/setup-build-utilities.ps1 @@ -57,7 +57,7 @@ find_or_fallback "diff grep" "$build_utilities_path\GnuWin\bin" find_or_fallback "cmake cpack" "$CMAKE_BIN" find_or_fallback "msbuild" "$MSBUILD_BIN" -if (-NOT (cpack.exe --help | grep 'CPACK_GENERATOR')) { +if (-NOT (cpack.exe --help | Select-String 'CPACK_GENERATOR')) { echo "Moving $CMAKE_BIN to front of PATH in order to find CMake's cpack" $CMAKE_BIN_ESCAPED = echo $CMAKE_BIN | sed 's#\\#\\\\#g' $path = (Invoke-Expression 'echo $Env:Path' | sed "s#;$CMAKE_BIN_ESCAPED##") @@ -65,7 +65,7 @@ if (-NOT (cpack.exe --help | grep 'CPACK_GENERATOR')) { } $ErrorActionPreference = "Continue" -if (-NOT (sort.exe /? 2>$null | grep "SORT")) { +if (-NOT (sort.exe /? 2>$null | Select-String "SORT")) { $ErrorActionPreference = "Stop" echo "Moving C:\WINDOWS\system32 to front of PATH in order to find Windows' sort" $path = (Invoke-Expression 'echo $Env:Path' | sed 's#;C:\\WINDOWS\\system32;#;#') @@ -90,14 +90,14 @@ $script:all_programs.Trim().Split(" ") | ForEach { # Special checks -if (-NOT (cpack.exe --help | grep 'CPACK_GENERATOR')) { +if (-NOT (cpack.exe --help | Select-String 'CPACK_GENERATOR')) { $exe = (Get-Command cpack.exe 2>$null).Source Write-Error -EA Continue "Found an unknown cpack at $exe" $exit_status = 1 } $ErrorActionPreference = "Continue" -if (-NOT (sort.exe /? 2>$null | grep "SORT")) { +if (-NOT (sort.exe /? 2>$null | Select-String "SORT")) { $ErrorActionPreference = "Stop" $exe = (Get-Command sort.exe 2>$null).Source Write-Error -EA Continue "Found an unknown sort at $exe"