Skip to content

Commit dc4302e

Browse files
compnerdplemarquand
authored andcommitted
utils: avoid redirection and use pipes for output redirection
When the output is directly redirected, the output is re-encoded. This is particularly important as `Write-PList` uses `Invoke-Program` to invoke `python.exe` to write the plist. However, because it is writing to a file, while the output from Python is in UTF-8, the redirection re-encodes the output to UTF16LE (BOM). Adjust the invocation to use PS7+ `2|` and pipe both stdout and stderr as appropriate into files with UTF-8 encoding restoring the encoding for the file.
1 parent 35cbdd8 commit dc4302e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

utils/build.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,13 +760,13 @@ function Invoke-Program() {
760760
if ($OutNull) {
761761
& $Executable @ExecutableArgs | Out-Null
762762
} elseif ($Silent) {
763-
& $Executable @ExecutableArgs *> $null
763+
& $Executable @ExecutableArgs | Out-Null 2>&1| Out-Null
764764
} elseif ($OutFile -and $ErrorFile) {
765-
& $Executable @ExecutableArgs > $OutFile 2> $ErrorFile
765+
& $Executable @ExecutableArgs | Out-File -FilePath $OutFile -Encoding UTF8 2>&1| Out-File -FilePath $ErrorFile -Encoding UTF8
766766
} elseif ($OutFile) {
767-
& $Executable @ExecutableArgs > $OutFile
767+
& $Executable @ExecutableArgs | Out-File -FilePath $OutFile -Encoding UTF8
768768
} elseif ($ErrorFile) {
769-
& $Executable @ExecutableArgs 2> $ErrorFile
769+
& $Executable @ExecutableArgs 2>&1| Out-File -FilePath $ErrorFile -Encoding UTF8
770770
} else {
771771
& $Executable @ExecutableArgs
772772
}

0 commit comments

Comments
 (0)