#!/bin/bash
#get the max num
echo;
echo "------test get the max num of two nums----- ";
EQUAL=0;
E_PARAM_ERR=-9999;
max2()
{
if [ -z "$2" ]
then
echo $E_PARAM_ERR;
return;
fi
if [ $1 -eq $2 ]
then
echo $EQUAL;
return;
else
if [ $1 -gt $2 ]
then
ret=$1;
else
ret=$2;
fi
fi
#can't use the return sentence,in here .
#because the method can return not big 255
echo $ret;
}
num=$(max2 200 500);
echo $num;
echo;
#get the max num
echo;
echo "------test get the max num of two nums----- ";
EQUAL=0;
E_PARAM_ERR=-9999;
max2()
{
if [ -z "$2" ]
then
echo $E_PARAM_ERR;
return;
fi
if [ $1 -eq $2 ]
then
echo $EQUAL;
return;
else
if [ $1 -gt $2 ]
then
ret=$1;
else
ret=$2;
fi
fi
#can't use the return sentence,in here .
#because the method can return not big 255
echo $ret;
}
num=$(max2 200 500);
echo $num;
echo;