Improving robustness of bash with error propagation