SC2278 – ShellCheck Wiki

See this page on GitHub


$0 can't be assigned in Ksh (but it does reflect the current function).

Problematic code:

echo "Usage: $0 --help"

Correct code:

myname() {
  echo "Usage: $0 --help"


You appear to be trying to assign a new value to $0 in Ksh.

This is not possible. However, $0 will reflect the current function name, so if you wrap your code in a function with your chosen name, you can have $0 expand to it.


If you instead wanted to compare the value of $0, use a comparison like [ "$0" = "myname" ].

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