Get exit status for a command correctly