mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-21 20:03:08 +02:00
1.0 KiB
1.0 KiB
description, applyTo
| description | applyTo |
|---|---|
| Use when writing or editing shell scripts in tools/, src/bin/, or src/infrastructure/. Covers bash conventions for XC_VM. | **/*.sh |
Bash Script Conventions — XC_VM
Required Header
#!/bin/bash
set -euo pipefail
Style
- Indent with 4 spaces (not tabs — unlike PHP)
- Quote all variables:
"$var"not$var - Use
[[ ]]for conditionals, not[ ] - Use
$()for command substitution, not backticks
Error Handling
set -e— exit on first errorset -u— treat unset variables as errorset -o pipefail— catch errors in pipes- Use
trapfor cleanup on exit when creating temp files
Security
- Never pass secrets via command-line arguments (visible in
ps) - Use environment variables or files with restricted permissions (0600)
- Validate external input before using in commands
- Avoid
evalunless absolutely necessary
Paths
- Use absolute paths for system binaries:
/usr/bin/php8.2,/usr/sbin/nginx - Reference project root via variable, not hardcoded paths