powershell doesn't flush stdout before a "break", sometimes even if you say [Console]::Out.Flush()
# outputs "hello":
try {
@("1") | ForEach-Object {
throw "fucking break doesn't work but this might"
}
}
catch {}
write-output "hello"
# exits silently:
@("1") | ForEach-Object {
break
}
write-output "hello"
# outputs list of members of array object:
@("1") | get-member
# exits silently:
@("1") | get-member
break
# exits silently:
$members = @("1") | get-member
write-output $members
break
# exits silently:
$members = @("1") | get-member
write-output $members
[Console]::Out.Flush()
break
# creates 'test.csv', indicating code above the break is still executing,
# but still exits silently. wtf?:
$members = @("1") | get-member
write-output $members
[Console]::Out.Flush()
write-output "flush dammit"
[Console]::Out.Flush()
$members | export-csv test.csv
write-output "flush dammit`n`n`n`n`nwtf"
[Console]::Out.Flush()
break