Guest_imported
New member
- Jan 1, 1970
- 0
have a shell script in which I have implemented functions. How do I return
a value back to the calling function. Here is an example.
#! /usr/bin/ksh
function testfunc
{
typeset -i a=1;
a=$((a+1))
return $a
}
echo "Now calling testfunc"
testfunc
echo "Now back"
echo $a
However I am not able to get the value of a which should now be 2. Can
someone suggest a solution. As an addendum I would like to know how to
return an entire array back to the calling function.
a value back to the calling function. Here is an example.
#! /usr/bin/ksh
function testfunc
{
typeset -i a=1;
a=$((a+1))
return $a
}
echo "Now calling testfunc"
testfunc
echo "Now back"
echo $a
However I am not able to get the value of a which should now be 2. Can
someone suggest a solution. As an addendum I would like to know how to
return an entire array back to the calling function.