文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>sehll中函数返回值范围

sehll中函数返回值范围

时间:2010-07-30  来源:sunjiangang-ok

通过下面的例子可以测试出shell中函数return的返回值为0--255
#!/bin/bash
#find the max one of two numbers
PARAM_ERR=256
PARAM_EQU=0
max2 ()
{
    if [ -z "$2" ]
    then
    return $PARAM_ERR
    fi
    
    if [ "$1" -eq "$2" ]
    then
    return $PARAM_EQU
    fi

    if [ "$1" -gt "$2" ]
    then
    return $1
    else
    return $2
    fi
}

max2 98 88
return_val=$?
if [ "$return_val" -eq "$PARAM_ERR" ]
then
echo "Need parameter"
elif [ "$return_val" -eq "$PARAM_EQU" ]
then
echo "They are equal"
else
echo "The max number is $return_val"
fi
 
相关阅读 更多 +
排行榜 更多 +
无敌流浪汉3手机版下载

无敌流浪汉3手机版下载

飞行射击 下载
杀戮尖塔mod手机版下载

杀戮尖塔mod手机版下载

棋牌卡牌 下载
ok交易平台官网免费版

ok交易平台官网免费版

金融理财 下载