为什么let--n的退出代码与bash中的let--n不同?
为什么它们的退出代码为1为什么let--n的退出代码与bash中的let--n不同?,bash,shell,Bash,Shell,为什么它们的退出代码为1 n=1 let --n 为什么退出代码为0 n=1 let n-- 这也有退出代码1。。。为什么? n=1 let "n = n - 1" 曼巴什说: let arg [arg ...] Each arg is an arithmetic expression to be evaluated (see ARITH‐ METIC EVALUATION above). If the last arg evaluates t
n=1
let --n
为什么退出代码为0
n=1
let n--
这也有退出代码1。。。为什么?
n=1
let "n = n - 1"
曼巴什说:
let arg [arg ...]
Each arg is an arithmetic expression to be evaluated (see ARITH‐
METIC EVALUATION above). If the last arg evaluates to 0, let
returns 1; 0 is returned otherwise.
1-1=0,因此退出代码为1。与
-n
之间的区别在于,第一项的值为n-1
(先递减,然后求值),而第二项的值为n
(后递减)。取值后,n总是少一个,但--
的位置表示何时应将值复制到结果中。只是好奇,为什么这个问题会投反对票?