feat: add shellcheckExternalSources config to make --external-sources optional#1376
Merged
skovhus merged 2 commits intobash-lsp:mainfrom Mar 6, 2026
Merged
Conversation
… optional The --external-sources flag is currently hardcoded in every ShellCheck invocation. On projects with many shell scripts that cross-source each other (e.g. 100+ scripts with source-path=SCRIPTDIR in .shellcheckrc), this causes exponential AST expansion — individual shellcheck processes grow to 3-5 GB RSS and never terminate. Adds a shellcheckExternalSources boolean config option (default: true for backward compatibility) and SHELLCHECK_EXTERNAL_SOURCES env var. When set to false, --external-sources is omitted from the ShellCheck invocation, preventing the unbounded memory growth. Fixes bash-lsp#874 Fixes bash-lsp#1375
This was referenced Mar 6, 2026
Closed
skovhus
approved these changes
Mar 6, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1376 +/- ##
==========================================
- Coverage 80.59% 80.56% -0.03%
==========================================
Files 29 29
Lines 1510 1513 +3
Branches 373 374 +1
==========================================
+ Hits 1217 1219 +2
Misses 235 235
- Partials 58 59 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
shellcheckExternalSourcesboolean config option (default:truefor backward compatibility) that controls whether--external-sourcesis passed to ShellCheck. When set tofalse, the flag is omitted, preventing unbounded memory growth on projects with many cross-sourcing shell scripts.Problem
The
--external-sourcesflag is currently hardcoded in every ShellCheck invocation (server/src/shellcheck/index.ts:142). On projects with many shell scripts that cross-source each other (e.g. 100+ scripts withsource-path=SCRIPTDIRin.shellcheckrc), this causes exponential AST expansion — individual shellcheck processes grow to 3-5 GB RSS and never terminate.With multiple editor sessions or headless AI coding tools (opencode, Claude Code) each spawning their own bash-language-server, this compounds rapidly. We observed 73 concurrent shellcheck processes consuming 17.8 GB RAM on a 64 GB machine.
The existing
shellcheckArgumentsconfig only appends arguments — there's no way to remove the hardcoded--external-sources.Changes
server/src/config.tsshellcheckExternalSourcesboolean config (defaulttrue) andSHELLCHECK_EXTERNAL_SOURCESenv varserver/src/shellcheck/index.tsexternalSourcestoLinterOptions, conditionally include--external-sourcesserver/src/server.tsconfig.shellcheckExternalSourceswhen constructingLintervscode-client/package.jsonbashIde.shellcheckExternalSourcesVS Code settingUsage
VS Code setting:
{ "bashIde.shellcheckExternalSources": false }Environment variable:
LSP initialization (for non-VS Code editors):
{ "shellcheckExternalSources": false }Backward Compatibility
Default is
true— existing behavior is unchanged. Only users who explicitly set it tofalsewill see the difference.Fixes #874
Fixes #1375