org.sonar.l10n.shellcheck.rules.shellcheck.SC2054.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
Use spaces, not commas, to separate array elements.
Problematic code
flags=("-l", "-d", "--sort=size")
ls "${flags[@]}"
Correct code
flags=("-l" "-d" "--sort=size")
ls "${flags[@]}"
Rationale
You appear to have used commas to separate array elements in an array assignment. Other languages require this, but bash instead treats the commas as literal strings.
In the problematic code, the first element is -l,
with the trailing comma, and the executed command ends up being ls -l, -d, --sort=size
.
In the correct code, the trailing commas have been removed, and the command will be ls -l -d --sort=size
as expected.
Exceptions
None (if you actually want a trailing comma in your strings, move them inside the quotes).
© 2015 - 2025 Weber Informatics LLC | Privacy Policy