Skip to content

Files

Latest commit

 

History

History
29 lines (18 loc) · 775 Bytes

SC1026.md

File metadata and controls

29 lines (18 loc) · 775 Bytes

Pattern: Malformed expression grouping in [[ .. ]] or [ .. ]

Issue: -

Description

[ .. ] 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.

Example of incorrect code:

[[ [ a || b ] && c ]]
[ [ a -o b ] -a c ]]

Example of correct code:

[[ ( a || b ) && c ]]
[ \( a -o b \) -a c ]]  # or  { [ a ] || [ b ]; } && [ c ]

Further Reading