bashsupport-pro
bashsupport-pro copied to clipboard
Feature Request: Support dash for shellcheck
For contributing to https://github.com/munin-monitoring/munin/ i would like to configure /bin/sh to be of type Dash. It seems currently only POSIX, Zsh and Bash are supported for BashSupport Pro.
When configuring /bin/sh to Dash i would like the shellcheck errors to match shellcheck -s dash.
See https://github.com/munin-monitoring/munin/pull/1439#discussion_r754299982
@ap-wtioit Thanks for reporting! There are two sides of this issue.
- ShellCheck: "dash" for ShellCheck is supported by BashSupport Pro. But, as you noticed,
*.shand#!/bin/share detected to be POSIX instead of dash. If there's a shebang line, then ShellCheck's logic kicks in (no override by BashSupport in this case). - Dash editor support: Good editor support is currently only available for POSIX and Bash. Dash-specific features are not supported in the editor.
Possible workaround: There's a setting "ShellCheck arguments" (https://www.bashsupport.com/manual/settings/), where you could define "-s dash" to override BashSupport Pro's and ShellCheck's autodetected values. Unfortunately, this is an application setting and this also applies to other projects. It would also apply to *.bash, so it's not ideal yet.
I'm currently not sure about the best way to fix this and still keeping it easy to understand.
An override mapping of file extension (e.g. *.sh) or shebang (e.g. #!/bin/sh) to the shell type (e.g. Dash) would be a better fix, but so far there isn't much demand for this.
@jansorg thanks for the quick response. I saw those settings for shellcheck and the side effects mentioned by you so i created this issue instead.
For me i think it's mainly https://github.com/koalaman/shellcheck/wiki/SC3043 (local varname) and i can disable this shellcheck warning with less side effects as its already mentioned in the wiki that most shells have it anyways.
With shell type mapping do you mean this dialog:

(Which is the one i had in mind as well)
@ap-wtioit I was just thinking, there's no such mapping yet. It would be similar to the table. The table in your screenshot is the list of default shell interpreters, used for run configurations, https://www.bashsupport.com/manual/run/
For your use case, are there only Dash files in your project or also other types like Bash or POSIX?
In this project .sh has both shebangs (#!/bin/sh using dash and #!/bin/bash using bash)