I recently learned 1 a nice pattern to improve parameter handling in shell scripts. The pattern involves parameter expansion: #!/usr/bin/env bash set -euo pipefail function main {localarg1="${A1:?'FAIL. Provide A1 var'}"echo$arg1}main When calling the script (called t.sh throughout this post), it will fail: bash t.sh # t.sh: line 7: A1: FAIL. Provide A1 var But this will succeed: A1=foo bash t.sh # foo It can also be used to provide default/required positional arguments.