LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash script and the , operator (https://www.linuxquestions.org/questions/programming-9/bash-script-and-the-operator-217360/)

xviddivxoggmp3 08-13-2004 10:16 PM

bash script and the , operator
 
I'm trying to understand a portion of the article posted at the below link.
http://www.tldp.org/LDP/abs/html/special-chars.html
Code:

let "t2 = ((a = 9, 15 / 3))"  # Set "a" and calculate "t2".
this example that was take from the article shows the that the equation obviously assigns two variables, but how would it know what to do with the following, if the following is valid.
Code:

let "t2 = ((10*25, 15 / 3))"
it says that it only returns the last operation, so would 10*25 be calculated and the product lost? other than the top most example is there any other real reason for this comma operator?

idaho 08-14-2004 12:33 AM

This is what I saw when I tried your code:
idaho@pikachu:~$ let "t2 = ((10*25, 15 / 3))";echo $t2
5

As you surmised, the 10*25 was calculated and discarded.


All times are GMT -5. The time now is 04:13 AM.