SC2280 – ShellCheck Wiki

See this page on GitHub


$0 can't be assigned this way, and there is no portable alternative.

Problematic code:


Correct code:

$0 can not be changed in a portable way.


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

There is no portable way to do this. Write around it, or switch to Bash.


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.