Thursday, April 9, 2009

Testing the correct number of parameters

E_WRONG_ARGS=85
script_parameters="-a -h -m -z"
# -a = all, -h = help, etc.

if [ $# -ne $Number_of_expected_args ]
then
echo "Usage: `basename $0` $script_parameters"
# `basename $0` is the script's filename.
exit $E_WRONG_ARGS
fi

No comments:

Post a Comment