Last active 1 day ago

rootiest's Avatar rootiest revised this gist 3 weeks ago. Go to revision

1 file changed, 11 insertions

bash-script-hygeine.md(file created)

@@ -0,0 +1,11 @@
1 + ### Bash Scripting Basic Hygiene Checklist
2 +
3 + | Task | Recommendation | Why? |
4 + | :--------------- | :---------------------- | :------------------------------------------------------------------- |
5 + | **The Shebang** | `#!/usr/bin/env bash` | Maximum portability across different Unix-like systems. |
6 + | **Error Handling** | `set -euo pipefail` | Ensures the script stops at the first sign of trouble. |
7 + | **Quoting** | **`"$VARIABLE"`** | Prevents word splitting and globbing (essential for paths). |
8 + | **Variable Style** | `local_var="value"` | Lowercase prevents overwriting system-wide environment variables. |
9 + | **Boilerplate** | `readonly CONSTANT` | Prevents accidental modification of fixed values. |
10 + | **Extensions** | `.sh` or none | Helps with syntax highlighting and identifying file types. |
11 + | **Permissions** | `chmod +x` | Use this tool to change permissions to make the script executable. |
Newer Older