When does an if statement need parentheses

I was looking at a script in my little book on bash and saw that one of the if statements had parentheses instead of brackets for the condition. I've been trying to find in my book where it talks about parentheses (because the examples on the if statement in an earlier chapter doesn't seem to mention them.

So I was wondering -- when are parentheses required for an if statement, and when are the brackets required? And could you tell me the syntax for the if statement when using parentheses?

Probably you mean the double parentheses construct which can be used in bash and ksh for arithmetic conditions..

if (( i > 1 )); then

Or maybe a subshell... Neither parenthesis nor brackets are required. Only a command (simple or a pipe) or a syntax construction that can return exit status is.

Shell if with no parens takes a single command execution string, possibly piped and subshell'd (), and a $? of 0 is true, like "if grep -q haha logfile ; then . . . ." The $? is from the last command, as I recall, so "if find . -type f|grep -q .profile ; then . . . ." tests the exit() value of grep and "if ( find . -type f >/tmp/myfiles ; grep -q .profile /tmp/myfiles ); then . . . ." also tests grep. (An extra fork() and named file open twice is probably more expensive than a pipe() call, slower because of latency and leaves a file behind.)