0
我試圖在開關盒循環中使用getopts。 如果我只使用getopts或只有開關的情況下工作,但是當我結合這兩個getopts dos不觸發。bash - 開關盒中的getopts
我有搜索了很多,但我的貓用散熱片的如何組合它們的任何提及,且問題我失去了一些東西愚蠢所以給我...
這裏是代碼的本質。
#!/bin/bash
case $1 in
ver)
echo "vesion"
exit 0
;;
op)
while getopts ":a" opt; do
case $opt in
a)
echo "-a was triggered!" >&2
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
;;
esac
當我這樣做
# bash -x test.sh op -a
我得到
+ case $1 in
+ getopts :a opt
(並沒有調試我什麼也沒有)
那是什麼,我缺少這兩個
結合謝謝:)
謝謝。工作完美 – yntnm