Automation · Bash Automation
Variables
Cheat sheet · https://pcornel.dk/topic.php?topic=5278
Answer
Bash variables are assigned without spaces (name=value) and read with "$name". They are untyped strings by default; use arrays for lists and declare -r for constants.
Remember
- Assign without spaces: name=value.
- Read with "$name" to keep spaces intact.
- Use arrays for lists and readonly for constants.
First checks
declare -p VAR— show variableshellcheck -i SC2086 script.sh— unquoted variablesreadonly CONST=value— constants
Verify in this order
value → variable → quoted use
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.
Bash Automation → Variables · operational reference
| Layer | Bash Automation → Variables operational reference |
|---|---|
| Context identity | GNU Bash 5.3/current + exact revision/input/target identity |
| Persistent intent | Versioned contract/configuration with explicit ownership and prerequisites |
| Verification | Validate inputs/read current state → exercise bounded operation → independent target read-back |
| Output contract | Preserve structured status/IDs/properties before human formatting |
| Failure boundary | Separate source/input/engine/controller execution from downstream target outcome |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5278