org.sonar.l10n.shellcheck.rules.shellcheck.SC1026.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
If grouping expressions inside [[..]], use ( .. ).
Problematic code
[[ [ a || b ] && c ]]
[ [ a -o b ] -a c ]]
Correct code
[[ ( a || b ) && c ]]
[ \( a -o b \) -a c ]] # or { [ a ] || [ b ]; } && [ c ]
Rationale
[ .. ]
should not be used to group subexpressions inside [[ .. ]]
or [ .. ]
statements.
For [[ .. ]]
, use regular parentheses.
For [ .. ]
, either use escaped parentheses, or preferably rewrite the expression into multiple [ .. ]
joined with &&
, ||
and { ..; }
groups. The latter is preferred because [ .. ]
is undefined for more than 4 arguments in POSIX.
Exceptions
None
Related resources
© 2015 - 2025 Weber Informatics LLC | Privacy Policy