Problem Statement
The codebase has inconsistent variable reference formatting - some use $var while others use ${var}. ShellCheck's SC2250 optional check can enforce the braced format (${var}) for consistency. Initial analysis shows 3,145 potential changes across 81 scripts.
Proposed Solution
Enable SC2250 in .shellcheckrc and remediate existing scripts:
- Add
enable=require-variable-braces to .shellcheckrc
- Create automated script to convert
$var to ${var}
- Run conversion across all shell scripts
- Validate no functional changes
Alternative Solutions
- Gradual adoption: Enable SC2250 but suppress existing violations, fix incrementally (slow, defeats purpose)
- Manual conversion: Fix each script by hand (time-consuming, error-prone)
- Do nothing: Accept inconsistent formatting (status quo)
Target Components
Implementation Ideas
Discovery command used:
shellcheck --enable=require-variable-braces --format=gcc *.sh 2>&1 | grep -c SC2250
Breakdown by directory:
| Directory |
SC2250 Warnings |
| scripts/ |
2,847 |
| src/100-edge/100-cncf-cluster/scripts/ |
113 |
| src/starter-kit/*/scripts/ |
142 |
| Other directories |
43 |
Automated fix approach:
- Use
sed or custom script to convert $var → ${var}
- Exclude special variables:
$@, $*, $?, $!, $$, $#, positional $1-$9
- Preserve quoted contexts
Additional Context
Benefits
- Consistent variable formatting across all scripts
- Improved readability and maintainability
- Eliminates ambiguity in variable boundaries (e.g.,
${var}suffix vs $varsuffix)
- Aligns with shell scripting best practices
Potential Challenges
- High volume of changes requires thorough testing
- Automated conversion must be carefully validated
- Some edge cases may need manual review
- Large PR may be difficult to review
Problem Statement
The codebase has inconsistent variable reference formatting - some use
$varwhile others use${var}. ShellCheck's SC2250 optional check can enforce the braced format (${var}) for consistency. Initial analysis shows 3,145 potential changes across 81 scripts.Proposed Solution
Enable SC2250 in
.shellcheckrcand remediate existing scripts:enable=require-variable-bracesto.shellcheckrc$varto${var}Alternative Solutions
Target Components
Implementation Ideas
Discovery command used:
Breakdown by directory:
Automated fix approach:
sedor custom script to convert$var→${var}$@,$*,$?,$!,$$,$#, positional$1-$9Additional Context
Benefits
${var}suffixvs$varsuffix)Potential Challenges