Automation · Bash Automation
Functions
Cheat sheet · https://pcornel.dk/topic.php?topic=5281
Answer
Bash functions group reusable commands, defined as name() { ...; }, with arguments in $1, $2 and local variables declared with local. They return a status code, not data.
Remember
- Arguments in $1, $2.
- Use local variables.
- Return status codes, print data.
First checks
declare -f <func>— function body- local variables inside functions — scope
- return codes — status
Verify in this order
args → function → status/output
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5281