Chinaunix

标题: why要写2层括号? [打印本页]

作者: w3wu    时间: 2008-05-04 15:05
标题: why要写2层括号?
i=0
while [ $i -lt 17 ]
do
.......
((i=i+1))
done


((i=i+1))---------why要写2层括号?看不懂。
作者: waker    时间: 2008-05-04 15:07
就这么约定的
作者: meyu    时间: 2008-05-04 17:40
(())是调用 let 命令,用于计算
作者: sdu_lizhipeng    时间: 2008-05-04 20:49
就是用(())来计算的.至于为什么不用三个括号或者四个,这个要问问语言设计者当初是怎么想....
作者: walkerxk    时间: 2008-05-05 09:14
bash是谁写的?
AUTHORS
Brian Fox, Free Software Foundation
bfox@gnu.org
Chet Ramey, Case Western Reserve University
chet@po.cwru.edu
去问问他们吧。
(list) list  is  executed in a subshell environment (see COMMAND EXECUTION ENVIRONMENT below).  Vari‐
              able assignments and builtin commands that affect the shell’s environment  do  not  remain  in
              effect after the command completes.  The return status is the exit status of list.
((expression))
              The  expression  is  evaluated according to the rules described below under ARITHMETIC EVALUA‐
              TION.  If the value of the expression is non-zero, the  return  status  is  0;  otherwise  the
              return status is 1.  This is exactly equivalent to let "expression".
我想一个括号的用掉了,接下来应该是用两个括号的,而不是三个、四个。





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2