【发布时间】:2021-12-24 07:15:08
【问题描述】:
我有以下脚本。
我想对其进行修改,以便如果我要使用这两个选项调用temp.sh,我将不得不将它们隔开。即:像temp.sh -fc30 这样的脚本调用应该是无效的,而应该是temp.sh -f -c 30
ARGS=$(getopt -o c:f -l "charlie:fox" -n "temp.sh" -- "$@");
#bad args
if [ $? -ne 0 ];
then
exit 1
fi
eval set --"$ARGS";
while true; do
case "$1" in
-c|--charlie)
shift;
if [ -n "$1" ]; then
echo "-c =: $1";
shift;
fi
;;
-f|--fox)
shift;
echo "fox used";
;;
--)
shift;
break;
;;
esac
done
【问题讨论】:
-
我很好奇你为什么要这么做。