What
Standardize quoting syntax, variable expansion, and coding style across all shell scripts in the /scripts/ directory to improve maintainability, robustness, and code quality.
Why
- Robustness: Inconsistent quoting can lead to failures with filenames containing spaces or special characters
- Maintainability: Consistent style makes code easier to read and modify
- Best practices: Align with industry-standard shell scripting guidelines
- Quality: Reduce technical debt and improve overall codebase quality
Scope
The following 8 shell scripts need review and standardization:
scripts/bootstrap.sh ⭐ (primary focus - most complex)
scripts/install.sh
scripts/uninstall.sh
scripts/un_bootstrap.sh
scripts/set_variables.sh
scripts/set_audience.sh
scripts/set_token.sh
scripts/test_endpoint.sh
Specific Improvements Needed
1. Variable Quoting and Expansion
- Current issues: Mixed quoting patterns (
$var vs "$var" vs "${var}")
- Target: Consistent use of
"${variable}" format throughout
- Example fixes:
# Before
gcloud services enable $service
grep -q $BUCKET
# After
gcloud services enable "${service}"
grep -q "${BUCKET}"
2. Command Substitution
- Current issues: Mixed quoting in command substitution
- Target: Consistent double-quote usage
- Example fix:
# Before
user=$(gcloud config list --format='value(core.account)')
# After
user=$(gcloud config list --format="value(core.account)")
3. Formatting and Style
- Line length: Break long commands at 80 characters for readability
- Spacing: Consistent section separation patterns
- Indentation: Standardize subshell and conditional indentation
4. Error Handling
- Current: Mix of
[ $? -ne 0 ] and [ $? -eq 0 ] patterns
- Target: Consistent error checking approach
- Consider: Using
set -e for automatic error handling where appropriate
Implementation Guidelines
Reference Standards
- Google Shell Style Guide
- Key principles:
- Always quote variables:
"${var}"
- Use
[[ ]] for tests instead of [ ]
- Maximum 80 character line length
- 2-space indentation
- Check return values consistently
Testing Requirements
- Ensure all scripts maintain current functionality after changes
- Test with edge cases (spaces in paths, special characters)
- Validate in both Bash and Zsh environments
Priority and Effort
- Priority: Low (enhancement/technical debt)
- Level of Effort: Medium (8 files, systematic changes needed)
- Timeline: Can be tackled incrementally or as time permits
Additional Considerations
- Consider adding a shell script linting CI check (shellcheck) after standardization
- Document any project-specific style decisions in CLAUDE.md
- This work can be done incrementally, focusing on the most complex scripts first
What
Standardize quoting syntax, variable expansion, and coding style across all shell scripts in the
/scripts/directory to improve maintainability, robustness, and code quality.Why
Scope
The following 8 shell scripts need review and standardization:
scripts/bootstrap.sh⭐ (primary focus - most complex)scripts/install.shscripts/uninstall.shscripts/un_bootstrap.shscripts/set_variables.shscripts/set_audience.shscripts/set_token.shscripts/test_endpoint.shSpecific Improvements Needed
1. Variable Quoting and Expansion
$varvs"$var"vs"${var}")"${variable}"format throughout2. Command Substitution
3. Formatting and Style
4. Error Handling
[ $? -ne 0 ]and[ $? -eq 0 ]patternsset -efor automatic error handling where appropriateImplementation Guidelines
Reference Standards
"${var}"[[ ]]for tests instead of[ ]Testing Requirements
Priority and Effort
Additional Considerations