# | not escaped
expr 1 | 2
# > not escaped
expr "$foo" >= "$bar"
# Missing spaces around +
expr 1+2
# Unexpected quoting around an expression
expr "1 + 2"
expr 16 \| 7
expr "$foo" \>= "$bar"
expr 1 + 2
ShellCheck found an expr
command with 1 or 2 arguments.
expr
normally expects 3 or more.
Generally, this happens for one of two reasons:
|
, &
,
>
, >=
, <
,
<=
, which needs to be escaped to avoid the shell
interpreting it as a pipe, backgrounded command, or redirection.Make sure each operator or operand to expr
is a separate
argument, and that anything containing shell metacharacters is escaped.
The correct code shows examples of each.
None
ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.