
org.sonar.l10n.shellcheck.rules.shellcheck.SC2277.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-shellcheck-plugin Show documentation
Show all versions of sonar-shellcheck-plugin Show documentation
ShellCheck plugin for SonarQube
The newest version!
Use BASH_ARGV0 to assign to $0 in bash (or use [ ] to compare).
Problematic code
#!/bin/bash
$0=myscriptname
Correct code
#!/bin/bash
BASH_ARGV0=myscriptname
Rationale
You appear to be trying to assign a new value to $0
in a Bash script. To do this, instead assign to the special variable BASH_ARGV0
.
If you instead wanted to compare the value of $0
, use a comparison like [ "$0" = "myname" ]
.
Exceptions
None.
Related resources
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
© 2015 - 2025 Weber Informatics LLC | Privacy Policy