Problem Statement
Some shell scripts source other scripts using relative paths from the script directory. ShellCheck cannot resolve these paths for static analysis, limiting lint coverage. Currently, these scripts require inline suppressions or are not fully validated.
Proposed Solution
Add source-path=SCRIPTDIR directive to .shellcheckrc:
- Add directive to enable relative path resolution
- Validate with existing sourcing patterns
- Document the directive's purpose
Validated patterns in codebase:
source "${SCRIPT_DIR}/env/.env"
source "${SCRIPT_DIR}/modules/logging.sh"
Alternative Solutions
- Inline directives per file: Add
# shellcheck source-path=SCRIPTDIR to individual files (inconsistent, clutters code)
- Absolute path refactoring: Rewrite sourcing to use absolute paths (breaks portability)
Target Components
Implementation Ideas
Add to .shellcheckrc:
# ShellCheck configuration
shell=bash
disable=SC1091
source-path=SCRIPTDIR
Verification steps:
- Run
shellcheck --format=gcc on scripts with relative sourcing
- Confirm no new errors introduced
- Confirm existing source patterns resolve correctly
Additional Context
Benefits
- Better static analysis coverage for sourced scripts
- Enables ShellCheck to follow source statements
- Improved lint quality without code changes
- Consistent configuration approach
Potential Challenges
- Limited impact initially - only affects scripts using
${SCRIPT_DIR} pattern
- May need additional source-path entries if other patterns exist
Problem Statement
Some shell scripts source other scripts using relative paths from the script directory. ShellCheck cannot resolve these paths for static analysis, limiting lint coverage. Currently, these scripts require inline suppressions or are not fully validated.
Proposed Solution
Add
source-path=SCRIPTDIRdirective to.shellcheckrc:Validated patterns in codebase:
source "${SCRIPT_DIR}/env/.env"source "${SCRIPT_DIR}/modules/logging.sh"Alternative Solutions
# shellcheck source-path=SCRIPTDIRto individual files (inconsistent, clutters code)Target Components
.shellcheckrcconfiguration fileImplementation Ideas
Add to
.shellcheckrc:# ShellCheck configuration shell=bash disable=SC1091 source-path=SCRIPTDIRVerification steps:
shellcheck --format=gccon scripts with relative sourcingAdditional Context
source-path=SCRIPTDIRworks with${SCRIPT_DIR}patternBenefits
Potential Challenges
${SCRIPT_DIR}pattern