0
我想驗證用戶輸入到一個小腳本我正在寫檢查,應該有:2個參數和第一個參數應該是枯萎「掛載」或「卸載」參數檢查controll邏輯和語法混淆
我有以下幾點:
if [ ! $# == 2 ] || [ $1 != "mount" -o $1 != "unmount" ]; then
但是它似乎有點overzelouse在符合條件我想要的。例如用當前的||運算符,沒有任何東西能通過驗證器,但如果我使用運算符,一切都會如此。
if [ ! $# == 2 ] && [ $1 != "mount" -o $1 != "unmount" ]; then
有人可以幫我解決這個問題嗎?
這裏是整個街區,並打算使用
if [ ! $# == 2 ] || [ $1 != "mount" -o $1 != "unmount" ]; then
echo "Usage:"
echo "encmount.sh mount remotepoint # mount the remote file system"
echo "encmount.sh unmount remotepoint # unmount the remote file system"
exit
fi
工作得很好,非常感謝。 – Hyposaurus 2013-02-27 10:00:34