fixing my poor bash to detect exit codes