
org.sonar.l10n.shellcheck.rules.shellcheck.SC2305.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!
Quote regex argument to expr to avoid it expanding as a glob.
Problematic code
expr "$input" : [0-9]*
Correct code
expr "$input" : "[0-9]*"
Rationale
ShellCheck found an expr
command using :
to match a regex, but the regex is not quoted and therefore being treated as a glob.
This means that if the problematic code is ever executed in a directory containing a file matching [0-9]*
, such as 2021-reports
or 12 Angry Men [1957].mkv
, it will be replaced be replaced and cause the command to error or incorrectly match.
The regex should be quoted to avoid this, like in the correct example.
Exceptions
None
Related resources
- Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
© 2015 - 2025 Weber Informatics LLC | Privacy Policy