Hi, for example I have this function:
function get_param ()
{
test=echo "some string"
test2=echo "someother string"
}
I want to call this function and get test or test2 result, how do I do that ?
Thank you
Hi, for example I have this function:
function get_param ()
{
test=echo "some string"
test2=echo "someother string"
}
I want to call this function and get test or test2 result, how do I do that ?
Thank you
you call the function and pass arguments to it by
function get_param ()
{
arg1="$1"
arg2="$2"
test="`date`"
test2="someother string"
#export test test2
}
echo "before function get_param test=$test"
echo "before function get_param test2=$test2"
echo "before function get_param arg1=$arg1"
echo "before function get_param arg2=$arg2"
get_param arg1 arg2
echo "after function get_param test=$test"
echo "after function get_param test2=$test2"
echo "after function get_param arg1=$arg1"
echo "after function get_param arg2=$arg2"
output
before function get_param test=
before function get_param test2=
before function get_param arg1=
before function get_param arg2=
after function get_param test=Sat Mar 27 15:23:00 EDT 2010
after function get_param test2=someother string
after function get_param arg1=arg1
after function get_param arg2=arg2
get_param()
{
case $1 in
test) echo "some string" ;;
test2) echo "some other string" ;;
esac
}