On Sun, Apr 8, 2012 at 12:50 AM, Linda Walsh <b...@tlinx.org> wrote: > > > Mike Frysinger wrote: > >> On Saturday 07 April 2012 16:45:55 Linda Walsh wrote: >>> >>> Is it an accidental omission from the bash manpage? >> >> >> it's in the man page. read the "Arithmetic Expansion" section. >> -mike > > > > ==== > My 4.2 manpage says: > > Arithmetic Expansion > Arithmetic expansion allows the evaluation of an arithmetic > expression > and the substitution of the result. The format for arithmetic > expan- > sion is: > > $((expression)) > > The expression is treated as if it were within double quotes, but > a > double quote inside the parentheses is not treated specially. > All > tokens in the expression undergo parameter expansion, string > expansion, > command substitution, and quote removal. Arithmetic expansions may > be > nested. > > The evaluation is performed according to the rules listed below > under > ARITHMETIC EVALUATION. If expression is invalid, bash prints a > message > indicating failure and no substitution occurs. > > ---------- > No mention of square brackets. > > What's yours say? > Some linux distributions patch the man page and document $[ ] as deprecated.
The SUS rationale says: In early proposals, a form $[expression] was used. It was functionally equivalent to the "$(())" of the current text, but objections were lodged that the 1988 KornShell had already implemented "$(())" and there was no compelling reason to invent yet another syntax. Furthermore, the "$[]" syntax had a minor incompatibility involving the patterns in case statements.