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