Variables
Cheat sheet · https://pcornel.dk/topic.php?topic=2688
Answer
Shell variables hold strings (name=value, no spaces around =) and are read with $name or ${name}. export makes them environment variables for child processes; local limits them to a function.
Remember
No spaces around =. Always quote when reading: "$name". Use ${name:-default} for defaults and ${name:?msg} to fail when unset. Variables set in a pipeline's subshell or a child script do not come back to the parent.
First checks
bash -x script.sh— trace each expanded commandbash -n script.sh— syntax check onlyshellcheck script.sh— common bugs and quoting problemsecho $?— exit code of the last command
Verify in this order
assignment → stored in the shell → optionally exported → expanded where used
Where it usually breaks
First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2688