SC1088 – ShellCheck Wiki

See this page on GitHub

Sitemap


Parsing stopped here. Invalid use of parentheses?

Problematic code:

grep ^(.*)\1$ file

or

var=myfunction(value)

Correct code:

grep '^(.*)\1$' file

or

var=$(myfunction value)

Rationale:

Parentheses are shell syntax and must be used correctly.

For commands that expect literal parentheses, such as grep or find, the parentheses need to be quoted or escaped so the shell does not interpret them, but instead passes them to the command.

For shell syntax, the shell does not use them the way most other languages do, so avoid guessing at syntax based on previous experience. In particular:

If you are trying to use parentheses for shell syntax, look up the actual syntax of the statement you are trying to use.

Exceptions:

None.


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.