我有以下一个bashscript:
function get_cms { echo "input cms name" read cms cms=${cms,} if [ "$cms" != "wordpress" && "$cms" != "meganto" && "$cms" != "typo3" ]; then get_cms fi }
但无论我输入什么(正确和不正确的值),它都不会再次调用该函数,因为我只想允许这3个输入中的1个.
我已经尝试了||使用[var!= value]或[var!= value1]或[var!= value1]
但没有什么工作.
有人可以指向正确的方向吗?
而不是说:
原文链接:https://www.f2er.com/bash/386232.htmlif [ "$cms" != "wordpress" && "$cms" != "meganto" && "$cms" != "typo3" ]; then
说:
if [[ "$cms" != "wordpress" && "$cms" != "meganto" && "$cms" != "typo3" ]]; then
您也可以参考Conditional Constructs.