LoveUnix » 编程开发 & Rational » 为什么我的getops中的case没起作用啊
让LU留住您的每

一天 让LU博客留住您的每一天
2005-12-17 18:44 happyhhhh2
为什么我的getops中的case没起作用啊

高手帮帮忙,我写了个简单的getops以便学习,可是系统当我输入./getopts.sh -x -y YANG -z GE *的时候,只有for里的echo显示出数据了,为什么没有打印出xopt,yopt,zopt的值啊,请问该如何做才能解决这个问题啊,下面是程序getopts.sh
while getopts ":xy:z:" opt;
do
case $opt in
        X ) xopt='-x set';;
        Y ) yopt="-y set and called with $OPTARG";;
        Z ) zopt="-z set and called with $OPTARG";;
        \? ) echo 'USAGE: getopts.sh [-x] [-y arg] [-z arg ] file ...'
          exit 1
  esac
done
shift $(($OPTIND - 1))
echo ${xopt: -'did not use -x'}
echo ${yopt: -'did not use -y'}
echo ${zopt: -'did not use -z'}
echo "Remaining command-line arguments are:"
for f in "$@"
do
  echo -e "$f"
done

[[i] 本帖最后由 happyhhhh2 于 2005-12-19 09:07 编辑 [/i]]

2005-12-19 11:16 jxppp
转shell。。:P

2005-12-20 09:12 happyhhhh2
什么意思??不明白请明示啊

页: [1]


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.