Pcornel
Automation · Bash Automation

Variables

Cheat sheet · https://pcornel.dk/topic.php?topic=5278

Back to the Topic

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 variable
  • shellcheck -i SC2086 script.sh — unquoted variables
  • readonly 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

LayerBash Automation → Variables operational reference
Context identityGNU Bash 5.3/current + exact revision/input/target identity
Persistent intentVersioned contract/configuration with explicit ownership and prerequisites
VerificationValidate inputs/read current state → exercise bounded operation → independent target read-back
Output contractPreserve structured status/IDs/properties before human formatting
Failure boundarySeparate 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

Confirmation

Confirm action

Continue?