我試圖寫一個bash腳本,解析傳遞到腳本參數:Azure的慶典CLI支持,做
while [[ $# -gt 0 ]]
do
case $1 in
-n|--name)
VMNAME="$2"
shift
shift
;;
-a|--admin-user)
ADMINUSERNAME="$2"
shift
shift
;;
-l|--location)
LOCATION="$2"
shift
shift
;;
-g|-resource-group)
RESOURCEGROUPNAME="$2"
shift
shift
;;
-a|--availability-set)
AVAILABILITYSETNAME="$2"
shift
shift
;;
*) # unknown option
echo unknwon "$1"
shift # past argument
;;
esac
done
echo "vn name = "
echo $VMNAME
echo "Admin User = " $ADMINUSERNAME
echo "Location = " $LOCATION
echo "Resource Group = " $RESOURCEGROUPNAME
echo "Availability Set = " $AVAILABILITYSETNAME
如果我ssh到我的Linux虛擬機並運行該腳本能正常工作。如果我嘗試從我的Azure的CLI執行該腳本,我得到了以下錯誤:
[email protected]:~/clouddrive$ bash test.bash -n test
test.bash: line 1: syntax error in conditional expression
'est.bash: line 1: syntax error near `]]
'est.bash: line 1: `while [[ $# -gt 0 ]]
如何在Azure CLI從Linux的bash shell的不同之處的它而言是編程語言的支持? Azure bash CLI支持哪種編程結構和流控制?
Newby錯誤!謝謝! – Jeremy