File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -32,19 +32,13 @@ function Invoke-Utf8ConsoleCommand([ScriptBlock]$cmd) {
32
32
# A native executable that writes to stderr AND has its stderr redirected will generate non-terminating
33
33
# error records if the user has set $ErrorActionPreference to Stop. Override that value in this scope.
34
34
$ErrorActionPreference = ' Continue'
35
- try {
36
- [Console ]::OutputEncoding = [Text.Encoding ]::UTF8
37
- & $cmd
38
- try {
39
- [Console ]::OutputEncoding = $currentEncoding
40
- }
41
- catch [System.IO.IOException ] {}
42
- }
43
- catch [System.IO.IOException ] {
44
- & $cmd
45
- }
35
+
36
+ try { [Console ]::OutputEncoding = [Text.Encoding ]::UTF8 } catch [System.IO.IOException ] {}
37
+ & $cmd
46
38
}
47
39
finally {
40
+ try { [Console ]::OutputEncoding = $currentEncoding } catch [System.IO.IOException ] {}
41
+
48
42
# Clear out stderr output that was added to the $Error collection, putting those errors in a module variable
49
43
if ($global :Error.Count -gt $errorCount ) {
50
44
$numNewErrors = $global :Error.Count - $errorCount
You can’t perform that action at this time.
0 commit comments