Skip to content

Files

Latest commit

 

History

History
27 lines (17 loc) · 696 Bytes

SC2233.md

File metadata and controls

27 lines (17 loc) · 696 Bytes

Pattern: Redundant (..) around condition

Issue: -

Description

You're wrapping (..) around one or more condition. This is unnecessary, and the resulting fork adds overhead. Delete the surrounding (..) since they serve no purpose and only slows the script down.

The shell syntax is if cmd, elif cmd, while cmd and until cmd without any parentheses. Parentheses are an independent construct used to create subshells.

Example of incorrect code:

if ([ "$x" -gt 0 ])
then true; fi

Example of correct code:

if [ "$x" -gt 0 ]
then true; fi

Further Reading