Skip to content

feat: better shell type detection#1367

Merged
skovhus merged 2 commits into
bash-lsp:mainfrom
intelfx:work/better-shell-detection
Jan 15, 2026
Merged

feat: better shell type detection#1367
skovhus merged 2 commits into
bash-lsp:mainfrom
intelfx:work/better-shell-detection

Conversation

@intelfx

@intelfx intelfx commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

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=busybox directive, we reject that directive because we do not know this dialect. Conversely, if the user does not specify a dialect in hopes of letting shellcheck figure it out, bash-language-server will implicitly pass a "guessed" dialect to shellcheck via a command line option, overriding its auto-detection.

  1. For immediate effect, add and recognize a new "busybox" shell type. This ie needed to be able to pass it to shellcheck, even if we do not act on it.
  2. In general, rework shell detection code such whenever a new shell dialect ever appears in future, we could handle it more gracefully even without recognizing it explicitly.

Comment thread server/src/util/shebang.ts
@skovhus

skovhus commented Jan 15, 2026

Copy link
Copy Markdown
Collaborator

Thanks! Seems like you just need to run linting/formatting.

@intelfx intelfx force-pushed the work/better-shell-detection branch from ea99d83 to a1b9a61 Compare January 15, 2026 17:17
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.
@intelfx intelfx force-pushed the work/better-shell-detection branch from a1b9a61 to 457f352 Compare January 15, 2026 17:21
@codecov

codecov Bot commented Jan 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.29412% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.55%. Comparing base (295659e) to head (457f352).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
server/src/util/shebang.ts 81.81% 3 Missing and 1 partial ⚠️
server/src/shellcheck/index.ts 87.50% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@skovhus skovhus merged commit d935091 into bash-lsp:main Jan 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants