Article 5DF7A Bash 'let' command in scripts

Bash 'let' command in scripts

by
dedec0
from LinuxQuestions.org on (#5DF7A)
I have read the bash man page about let command:

Code:let arg [arg ...]
Each arg is an arithmetic expression
to be evaluated (see ARITHMETIC EVALU
ATION above). If the last arg evalu
ates to 0, let returns 1; 0 is
returned otherwise.But on this script i am reading, it is written this:

Code:function push_pieces {
case $4 in
"up")
let "first=$2*$board_size+$1"
let "second=($2+$3)*$board_size+$1"
;;
"down")
let "first=(index_max-$2)*$board_size+$1"
let "second=(index_max-$2-$3)*$board_size+$1"
;;
"left")
let "first=$1*$board_size+$2"
let "second=$1*$board_size+($2+$3)"
;;
"right")
let "first=$1*$board_size+(index_max-$2)"
let "second=$1*$board_size+(index_max-$2-$3)"
;;
esac

# [...]

}In each case possibility, are the variables $first and $second being evaluated with a mathematical expression that follows them? It is very strange because "$board_size" has a dolar sign, "index_max" does not, and "first" and "second" also do not.latest?d=yIl2AUoC8zA latest?i=LZ2uq0Hs2H4:_liKnm3DKJU:F7zBnMy latest?i=LZ2uq0Hs2H4:_liKnm3DKJU:V_sGLiP latest?d=qj6IDK7rITs latest?i=LZ2uq0Hs2H4:_liKnm3DKJU:gIN9vFwLZ2uq0Hs2H4
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments