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