feat: better shell type detection#1367
Merged
Merged
Conversation
skovhus
reviewed
Jan 15, 2026
Collaborator
|
Thanks! Seems like you just need to run linting/formatting. |
ea99d83 to
a1b9a61
Compare
Perform a more rigorous shell type (dialect) detection to avoid interfering with shellcheck. In particular, track whether we detected a shell dialect from the shebang, `shellcheck shell=...` directive or the file name (URI). When invoking shellcheck, only pass an override (i.e., the `--shell=` argument) or bail out on an unsupported dialect if we guessed something that is not in the document text. Otherwise, do not pass _anything_ and let shellcheck work it out on its own because it's smarter than us. This makes sure that 1) the user can always override our logic with a `shell=` directive; 2) we handle unknown shell types as gracefully as possible.
a1b9a61 to
457f352
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1367 +/- ##
==========================================
- Coverage 80.74% 80.55% -0.19%
==========================================
Files 29 29
Lines 1501 1502 +1
Branches 371 371
==========================================
- Hits 1212 1210 -2
- Misses 231 234 +3
Partials 58 58 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
This PR improves bash-language-server behavior around unrecognized shell types, such as busybox sh. Currently, bash-language-server does not recognize busybox shell, but it also actively prevents shellcheck from recognizing it either.
Even if user specifices one directly via a
shellcheck shell=busyboxdirective, we reject that directive because we do not know this dialect. Conversely, if the user does not specify a dialect in hopes of lettingshellcheckfigure it out, bash-language-server will implicitly pass a "guessed" dialect to shellcheck via a command line option, overriding its auto-detection.