I have two shell script like as follows:
a.sh
tes=2
testfunction(){
tes=3
echo 5
}
testfunction
echo $tes
b.sh
tes=2
testfunction(){
tes=3
echo 5
}
val=$(testfunction)
echo $tes
echo $val
In first script tes
value is '3' as expected but in second it's 2?
Why is it behaving like this?
Is $(funcall)
creating a new sub shell and executing the function? If yes, how can address this?