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

Declaring bash functions using the function keyword, with function body in parens #2651

Open
2 tasks done
DrHyde opened this issue Jan 1, 2023 · 0 comments
Open
2 tasks done

Comments

@DrHyde
Copy link

DrHyde commented Jan 1, 2023

For bugs

  • Rule Id (if any, e.g. SC1000):

SC1073, SC1065, SC1064, SC1072

  • My shellcheck version (shellcheck --version or "online"):

0.9.0

Here's a snippet or screenshot that shows the problem:

#!/usr/bin/env bash
function foo ( pwd )

Here's what shellcheck currently says:

$ shellcheck foo

In foo line 2:
function foo ( pwd )
^-- SC1073 (error): Couldn't parse this function. Fix to allow more checks.
               ^-- SC1065 (error): Trying to declare parameters? Don't. Use () and refer to params as $1, $2..


In foo line 3:

^-- SC1064 (error): Expected a { to open the function definition.
^-- SC1072 (error):  Fix any mentioned problems and try again.

For more information:
  https://www.shellcheck.net/wiki/SC1064 -- Expected a { to open the function...
  https://www.shellcheck.net/wiki/SC1065 -- Trying to declare parameters? Don...
  https://www.shellcheck.net/wiki/SC1072 --  Fix any mentioned problems and t...

Here's what I wanted or expected to see:

Either nothing, or if shellcheck strongly prefers that the function be defined as foo() ( pwd ) (it doesn't complain about that at all) it should say so.

Having the function body in parens instead of braces is kosher, it just means that the function body is executed in a sub-shell.

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

No branches or pull requests

1 participant