测试脚本被调用的参数数量是否正确

#!/bin/bash


E_WRONG_ARGS=65

scripts_parameters="-a -h -m -z"

# -a = all , -h = help , 等等


if [ $# -ne $Number_of_expected_args ]

then

        echo "Usage: `basename $0` $script_parameters"

        # `basename $0` 是这个脚本的文件名

        exit $E_WRONG_ARGS

fi


你可能感兴趣的:(shell,测试,被调用)