manpagez: man pages & more
info autoconf
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.8 Parentheses in Shell Scripts

Beware of two opening parentheses in a row, as many shell implementations treat them specially. Posix requires that the command ‘((cat))’ must behave like ‘(cat)’, but many shells, including Bash and the Korn shell, treat ‘((cat))’ as an arithmetic expression equivalent to ‘let "cat"’, and may or may not report an error when they detect that ‘cat’ is not a number. As another example, ‘pdksh’ 5.2.14 misparses the following code:

 
if ((true) || false); then
  echo ok
fi

To work around this problem, insert a space between the two opening parentheses. There is a similar problem and workaround with ‘$((’; see Shell Substitutions.


© manpagez.com 2000-2018
Individual documents may contain additional copyright information.