mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
This commit is contained in:
committed by
Paul LeMarquand
parent
35cbdd8dab
commit
dc4302e65d
@@ -760,13 +760,13 @@ function Invoke-Program() {
|
|||||||
if ($OutNull) {
|
if ($OutNull) {
|
||||||
& $Executable @ExecutableArgs | Out-Null
|
& $Executable @ExecutableArgs | Out-Null
|
||||||
} elseif ($Silent) {
|
} elseif ($Silent) {
|
||||||
& $Executable @ExecutableArgs *> $null
|
& $Executable @ExecutableArgs | Out-Null 2>&1| Out-Null
|
||||||
} elseif ($OutFile -and $ErrorFile) {
|
} elseif ($OutFile -and $ErrorFile) {
|
||||||
& $Executable @ExecutableArgs > $OutFile 2> $ErrorFile
|
& $Executable @ExecutableArgs | Out-File -FilePath $OutFile -Encoding UTF8 2>&1| Out-File -FilePath $ErrorFile -Encoding UTF8
|
||||||
} elseif ($OutFile) {
|
} elseif ($OutFile) {
|
||||||
& $Executable @ExecutableArgs > $OutFile
|
& $Executable @ExecutableArgs | Out-File -FilePath $OutFile -Encoding UTF8
|
||||||
} elseif ($ErrorFile) {
|
} elseif ($ErrorFile) {
|
||||||
& $Executable @ExecutableArgs 2> $ErrorFile
|
& $Executable @ExecutableArgs 2>&1| Out-File -FilePath $ErrorFile -Encoding UTF8
|
||||||
} else {
|
} else {
|
||||||
& $Executable @ExecutableArgs
|
& $Executable @ExecutableArgs
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user