Variables
Cheat sheet · https://pcornel.dk/topic.php?topic=5214
Answer
Variables hold runtime values and state inside a script; reliable use requires clear scope, type/shape expectations, initialization, lifetime and protection of sensitive values.
Remember
- Variable assigned ≠ value valid; a non-empty value can still be malformed, stale or unauthorized.
- Global availability ≠ correct ownership; wide scope increases coupling and hidden side effects.
- String representation ≠ semantic type; numeric, boolean, date and structured values require deliberate parsing.
- Secret stored in a variable ≠ secret protected; process memory, debug output and child-process inheritance may expose it.
First checks
shellcheck script.sh (SC2086 unquoted)— quotingdeclare -p <var>— inspect Bash variableGet-Variable <name>— PowerShell
Verify in this order
value → variable → used safely
Where it usually breaks
A variable containing a value proves only that data is present in memory; it does not prove origin, validity, freshness, authorization or correctness for the downstream action.
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
Variables scripting boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Input / runtime | Effective inputs, runtime, working context and dependency versions are explicit | Hidden defaults, stale environment, wrong interpreter/path or unvalidated input |
| Logic / execution | Branch/function/module decisions and external actions expose per-operation results | Swallowed failures, shell reinterpretation, blind retries or last-result-wins behavior |
| Result / proof | Exit/exception/log evidence is correlated with independent target read-back | Process success or printed output treated as target success |
| Recovery / troubleshooting | First failed boundary is preserved, changed minimally and retested | Random edits, catch-all suppression or evidence destroyed before diagnosis |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5214