Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for Vim's shell type buffer variables before falling back to the file type #3427

Merged
merged 3 commits into from
Nov 4, 2020

Conversation

lifecrisis
Copy link
Contributor

This PR fixes an interesting error I noticed when working on shell scripts that don't have a #! line.

To reproduce:

  1. create a "test.bash" file, with no #! line
  2. open the file and verify that b:is_bash is set
  3. notice that, when using shellcheck the file is linted as a simple sh file

This is because we fall back to the file type before checking for buffer-local shell type variables.

See my commit messages for more details.

Thanks!

Jason Franklin added 3 commits November 2, 2020 10:46
The "ale#handlers#sh#GetShellType()" function currently falls back
to the file type without checking for buffer-local variables first.
This causes the function to return "sh" even when a script is known
by Vim to be a script of a more specific type (e.g., "bash").

The "ale#handlers#shellcheck#GetDialectArgument()" function then
erroneously uses this type even though a more fitting type should be
used instead.  Files without a "#!" line will be of type "sh" even
though they may have a ".bash" suffix.

This commit fixes the problem by checking for buffer-local shell
type variables (set by Vim) before falling back to the file type.
Copy link
Contributor

@hsanson hsanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@hsanson hsanson merged commit 1ec573b into dense-analysis:master Nov 4, 2020
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.

None yet

2 participants