Failure signals
Three articles about scripts that report success for work that didn't happen. Each takes a different runtime (PowerShell, cmd.exe, the AWS CLI) and asks the same question: what did this command actually tell you when it failed?
3 parts · 3 published

- Part 1
Why $LASTEXITCODE Doesn't Work the Way You Expect in PowerShell
Cmdlets never set LASTEXITCODE, so after a failed cmdlet it still holds whatever the last native program returned, often zero.
- Part 2
Why Does My Batch File Exit When I Call a Function?
The subroutine runs before anything calls it, and its goto :eof ends the whole script, because cmd.exe reads straight down through a label.
- Part 3
AWS CLI sync vs. Write-S3Object: What Changes on the Second Run
Write-S3Object is wrong for repeat runs into a versioned bucket, which keeps every copy; sync is wrong when a restored file keeps its size and old timestamp.