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
SC1036 for function declaration "==== () { echo test; }" #2047
Comments
This is a bash bug. This should be illegal: https://stackoverflow.com/questions/28114999/what-are-the-rules-for-valid-identifiers-e-g-functions-vars-etc-in-bash . |
It's really not entirely clear; The discussion also shows that this interpretation of the documentation doesn't match the actual behavior of bash, with backwards-compatibility requirements making future changes unlikely. Bash does however reject the identifier when invoked as On the other hand,
|
As a workaround, you can use The general problem has been that bash accepts a lot of strange names, e.g. To avoid suggesting "Maybe you're missing () in a function" whenever you write random gibberish, it therefore only allows particularly weird characters after a |
Assuming you are talking about the function name, shellcheck allows hello-world probably because, although invalid according time the docs, it is works in bash to have dashes in function names. Not identifiers though. If you’re talking about the :;, then disregard. |
It does warn for sh and dash as part of the bashism checks. It's simply missing the same for ksh. |
How to reproduce
Give ShellCheck the following script:
Seen output
Expected output
None. In Bash scripts,
====
is a valid identifier. This can be used e.g. to combine structuring a script with headings and producing progress output at the same time.However, it looks like this is very specific to Bash. Both
ksh
andsh
complain about different syntax errors caused by an invalid identifier.The text was updated successfully, but these errors were encountered: