At top of your bash script add this after `#!/bin/bash` line to aborts the script immediately and add robustness to your script
```
set -euo pipefail
```

Use the following to trap error and show line number where your script failed to debut at run time or development time:
```
_failed() {
echo "$0 - Script failed at line $1"
}

# Trap the ERR
trap '_failed $LINENO' ERR
```

See `man bash` or `help set` for more.

0

If you have a fediverse account, you can quote this note from your own instance. Search https://mastodon.social/users/nixCraft/statuses/116080348598352991 on your instance and quote it. (Note that quoting is not supported in Mastodon.)