#!/bin/bash
# Desc: dataworks任務診段
# Author:Liuhl
# Date:2020-02-22
####################################
# getopt -T
# ARGS=`getopt -o ab:c:: --long along,blong:,clong:: -n "getopt.sh" -- "$@"`
# if [ $? != 0 ];then
# echo "Terminating" >&2;exit 1
# fi
ARGS=`getopt -o ab:c:: --long along,blong:,clong:: -n 'test.sh' -- "$@"`
if [ $? != 0 ];then
echo "Terminating..."
exit 1
fi
eval set -- "${ARGS}"
while true
do
case "$1" in
-a|--along)
echo "option a"
shift ;;
-b|--blong)
echo "option b argument $2"
shift 2;;
-c|--clong)
case "$2" in
"")
echo "Option c, no argument"
shift 2;;
*)
echo "option c, argumnt $2"
shift 2;;
esac
;;
--)
shift
break
;;
*)
echo "Internal error!"
exit 1
;;
esac
done
getopt應用demo
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.