In csh, why does 4 - 3 + 1 == 0?

前端 未结 3 800
猫巷女王i
猫巷女王i 2021-01-17 11:11
#!/bin/csh

@ cows = 4 - 3 + 1
echo $cows

This simple csh script when run produces \"0\" for output when I\'d expect \"2\".

~root:          


        
3条回答
  •  有刺的猬
    2021-01-17 11:23

    The + and - operators are right-associative in csh. This means that '4 - 3 + 1' is evaluated as '4 - (3 + 1)'.

提交回复
热议问题