Here we are calling functions directly using 'type' after parsing them in SUB_CMD through command line:
##############################################
PROG_NAME="$(basename $0)"
SUB_CMD="$1"
retval=0
if [ "$(type -t "${SUB_CMD}")" == 'function' ] ; then
${SUB_CMD}
retval=$?
else
echo "Invalid command '${SUB_CMD}'"
usage
retval=1
fi
exit ${retval}
##############################################
##############################################
PROG_NAME="$(basename $0)"
SUB_CMD="$1"
retval=0
if [ "$(type -t "${SUB_CMD}")" == 'function' ] ; then
${SUB_CMD}
retval=$?
else
echo "Invalid command '${SUB_CMD}'"
usage
retval=1
fi
exit ${retval}
##############################################
Comments
Post a Comment