SC2111 – ShellCheck Wiki

See this page on GitHub


ksh does not allow function keyword and () at the same time.

Problematic code:

function foo() {
  echo "Hello World"

Correct code:

# POSIX sh function
foo() {
  echo "Hello World"


# ksh extended function
function foo {
  echo "Hello World"


Ksh allows two ways of defining functions: POSIX sh style foo() { ..; } and Ksh specific function foo { ..; }.

ShellCheck found a function definition that uses both at the same time, function foo() { ..; } which is not allowed. Use one or the other.

Note that the two are not identical, for example:


In Bash, function foo() { ..; } is allowed, and function foo and foo() are identical. This warning does not trigger when the shebang is e.g. #!/bin/bash.

ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.