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

11.10 Parentheses in Shell Scripts

Beware of two opening parentheses in a row, as many shell implementations treat them specially, and Posix says that a portable script cannot use ‘((’ outside the ‘$((’ form used for shell arithmetic. In traditional shells, ‘((cat))’ behaves 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 does not treat the following code as a traditional shell would:

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.


This document was generated on April 26, 2012 using texi2html 5.0.

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