shell判断是否有传参到脚本当中

function checkParm(){
    if [ ! -n "$1" ];then
        echo "Parm Doesn't exist,don't run this shell"
        exit 1
    fi
}

checkParm

主要是通过第一个参数判断,脚本是否有入参,如果无入参则退出脚本执行,返回异常退出码1

猜你喜欢

转载自blog.csdn.net/huangzx3/article/details/81080084
今日推荐