script interpreting - "let"
I'm currently reading this:
http://www.tldp.org/LDP/abs/abs-guide.pdf What is the meaning of the following? let "t2 = ((a = 9, 15 / 3))" # Set "a = 9" and "t2 = 15 / 3" I don't understand the relationship between t2 and a here. Is the answer in the comment correct? |
Code:
echo $a |
Well, ok, it's correct, but that wasn't actually the question, obviously. I don't understand why this is happening.
|
"a = 9" is an expression with the side effect of setting the value of variable a. It returns that value.
"," is an operator that evaluates both of its operands and returns the value of its second operand. |
You need to start reading the expression from inside the parentheses:
Code:
a = 9 The result of Code:
15 / 3 Code:
let "t2 = ((9, 5))" Code:
let "t2 = ((5))" |
This is a quite unusual case. I mean this is not the way how it was planned to use. Especially the , (comma) operator. Which is actually uncommon/unusual.
here you can find a bit more: http://unix.stackexchange.com/questi...ash-arithmetic |
Quote:
Thank you for the explanations and references. |
All times are GMT -5. The time now is 11:52 PM. |