Scripting Fundamentals
Cheat sheet · https://pcornel.dk/topic.php?topic=5213
Answer
Scripting Fundamentals defines the minimum structure of a reliable automation script: explicit entry point, inputs, runtime assumptions, bounded logic, external actions, result semantics and verification.
Remember
- Readable script ≠ reliable script; structure must expose failure and verification boundaries, not only improve formatting.
- Main routine completed ≠ every external operation succeeded; child command and API results require explicit handling.
- Reusable function ≠ safe orchestration; calling order, shared state and side effects still matter.
- Dry syntax check ≠ runtime validation; environment, permissions, dependencies and target behavior remain unproven.
First checks
bash -n script.sh— syntaxshellcheck script.sh— lint- Header: purpose, usage, author — documentation
Verify in this order
script → interpreter → actions → exit code
Where it usually breaks
A well-structured script improves explainability and failure propagation; it does not prove the business or infrastructure outcome until the external target is checked.
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
Scripting Fundamentals 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=5213