Prompt
Always use proper quoting in shell scripts (especially GitHub Actions workflows) to prevent word splitting, globbing, and ensure correct variable expansion:
- Use double quotes around variable expansions and command substitutions to prevent word splitting:
# Incorrect go list -f '/...' -m | xargs go test -short -covermode=atomic -timeout=5m # Correct go list -f '/...' -m | xargs bash -c "go test -short -covermode=atomic -timeout=5m" - Use double quotes (not single quotes) when you need variable expansion:
# Incorrect - variables won't expand in single quotes echo 'Value: $SOME_VAR' # Correct - allows variable expansion echo "Value: $SOME_VAR" - Always quote variables in conditions and arguments to prevent unexpected behavior:
# Incorrect if [ $status == success ]; then # Correct if [ "$status" == "success" ]; then
These practices prevent common shell scripting errors that tools like shellcheck will flag (SC2046, SC2016, SC2086), resulting in more robust and predictable scripts.