Shellcheck: finer grained control over shell dialect features

Created on 20 Sep 2018  路  2Comments  路  Source: koalaman/shellcheck

today shellcheck has one big knob to control dialect: the -s option. we'd like to run shellcheck against scripts and say it's the POSIX dialect but with support for local. our options today are not optimal:

  • use --shell=dash, but then silently allow dashisms
  • use --shell=bash, but then silently allow bashisms
  • use --shell=sh -e SC2039, but then silently allow all undefined things

it looks like dialect details are sprinkled through out the code base:

  • ] ++ if not isDash then ["local"] else []
  • whenShell [Bash, Dash] $ do -- Ksh allows it, Sh doesn't support local

if the dialect details were split out into a data structure (a dict/map), and all the code checked that data structure, it'd be easy to expose those to the command line as people could set specific dialect features directly.

on the other hand, if we consider local a common enough thing, adding a one-off knob for it would be OK too :).

Most helpful comment

SC2039 should really have had a separate error code per issue, that way you could just have ignored that particular one.

All 2 comments

@yetamrra another use case that would be covered by this is defining dialects for projects. for example, linting Gentoo ebuild/eclass files follow a particular set of rules that we'd like to be able to enforce.

SC2039 should really have had a separate error code per issue, that way you could just have ignored that particular one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxisme picture maxisme  路  3Comments

arth1 picture arth1  路  4Comments

quchen picture quchen  路  3Comments

erwinkramer picture erwinkramer  路  5Comments

koalaman picture koalaman  路  4Comments