<!--
title: Standardize bash error-handling
domain: cloud-infra
topic: Error Handling
language: Shell
source: chef/chef
updated: 2025-06-12
url: https://awesomereviewers.com/reviewers/chef-standardize-bash-error-handling/
-->

Always use `set -eou pipefail` at the beginning of bash scripts to ensure consistent and robust error handling. This combination ensures scripts fail immediately on errors (`-e`), treat unset variables as errors (`-u`), and properly handle pipeline failures (`-o pipefail`), preventing silent failures and making debugging easier.

```bash
# Good practice
#!/bin/bash
set -eou pipefail

# Rest of your script
```
