dense-analysis / dense-analysis/ale
ALE tells ShellCheck to treat files with the ".bash" extension as sh files when vim-polyglot is enabled
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
## Information
**VIM version**
```
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 08 2021 14:19:29)
Included patches: 1-2434, 3402-3403, 3409, 3428, 3487, 3564, 3581-3582
```
Operating System: Ubuntu 21.04
## What went wrong
When ALE and vim-polyglot are both enabled, ALE tells ShellCheck that files ending with a *.bash* extension are of type *sh*.
## Reproducing the bug
### Steps to reproduce
1. Install ShellCheck
2. `mv ~/.vim ~/.vim.bak.ale-issue-3988.$(date '+%s')`
3. `git clone --depth 1 https://github.com/dense-analysis/ale.git ~/.vim/pack/plugins/start/ale`
4. `git clone --depth 1 https://github.com/sheerun/vim-polyglot ~/.vim/pack/plugins/start/vim-polyglot`
5. `vim example.bash`
6. Enter the following contents:
```bash
function example() {
echo 'example'
}
```
### Actual results
`:ALEInfo` reports that option `-s sh` is passed to ShellCheck. ShellCheck reports the following error, which only applies to POSIX sh:
```
SC2112: 'function' keyword is non-standard. Delete it.
```
### Expected results
`:ALEInfo` reports that option `-s bash` is passed to ShellCheck and ShellCheck reports no errors.
### :ALEInfo
```
Current Filetype: sh
Available Linters: ['bashate', 'cspell', 'language_server', 'shell', 'shellcheck']
Enabled Linters: ['bashate', 'cspell', 'language_server', 'shell', 'shellcheck']
Ignored Linters: []
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'shfmt' - Fix sh files with shfmt.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_sh_bashate_executable = 'bashate'
let g:ale_sh_bashate_options = ''
let g:ale_sh_language_server_executable = 'bash-language-server'
let g:ale_sh_language_server_use_global = 0
let g:ale_sh_shell_default_shell = 'bash'
let g:ale_sh_shellcheck_change_directory = 1
let g:ale_sh_shellcheck_dialect = 'auto'
let g:ale_sh_shellcheck_exclusions = ''
let g:ale_sh_shellcheck_executable = 'shellcheck'
let g:ale_sh_shellcheck_options = ''
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 0
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_sign_highlight_linenrs = 0
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - failure) bashate
(executable check - failure) cspell
(executable check - success) sh
(finished - exit code 0) ['/bin/bash', '-c', 'sh -n ''/tmp/vZUaM5c/1/example.bash''']
<<>>
(executable check - success) shellcheck
(finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/john'' && ''shellcheck'' --version']
<<>>
ShellCheck - shell script analysis tool
version: 0.7.1
license: GNU General Public License, version 3
website: https://www.shellcheck.net
<<>>
(finished - exit code 0) ['/bin/bash', '-c', 'cd ''/home/john'' && ''shellcheck'' -s sh -x -f gcc - < ''/tmp/vZUaM5c/2/example.bash''']
<<>>
(executable check - failure) bashate
(executable check - failure) cspell
(finished - exit code 2) ['/bin/bash', '-c', 'sh -n ''/tmp/vZUaM5c/3/example.bash''']
<<>>
/tmp/vZUaM5c/3/example.bash: 1: Syntax error: "(" unexpected
<<>>
(finished - exit code 1) ['/bin/bash', '-c', 'cd ''/home/john'' && ''shellcheck'' -s sh -x -f gcc - < ''/tmp/vZUaM5c/4/example.bash''']
<<>>
-:1:1: note: The mentioned syntax error was in this function. [SC1009]
-:1:20: error: Couldn't parse this brace group. Fix to allow more checks. [SC1073]
-:2:1: error: You need at least one command here. Use 'true;' as a no-op. [SC1055]
-:2:2: error: Unexpected keyword/token. Fix any mentioned problems and try again. [SC1072]
<<>>
(executable check - failure) bashate
(executable check - failure) cspell
(finished - exit code 2) ['/bin/bash', '-c', 'sh -n ''/tmp/vZUaM5c/5/example.bash''']
<<>>
/tmp/vZUaM5c/5/example.bash: 1: Syntax error: "(" unexpected
<<>>
(finished - exit code 1) ['/bin/bash', '-c', 'cd ''/home/john'' && ''shellcheck'' -s sh -x -f gcc - < ''/tmp/vZUaM5c/6/example.bash''']
<<>>
-:1:1: warning: 'function' keyword is non-standard. Delete it. [SC2112]
<<>>
```
## Other notes
This works as expected if vim-polyglot is not enabled when Vim starts up, e.g., if the steps above are repeated and step 4 is skipped.
Contributor guide
Assessment
This issue has not been assessed yet.