我应该在“then”前面加空格吗?

我应该在“then”前面加空格吗?

我收到基于“then”的错误。我应该在它前面加空格吗?

winning=$(( RANDOM % 15 ))
while [[${guess}-ne ${winning}]]; then
   read -p "guess a number from 0 to 15: " guess
   if [[${guess}-ne ${winning}]]; then
      echo "Your guess, ${guess}, was incorrect. Guess again to win a \$200 Guess handbag."
   fi
done
echo "Congrats! You got it! ${guess}"
exit 0

答案1

看起来您已经找到了答案,但对于那些在家观看的人来说,then仅适用于 if 语句。在 while 循环中,您应该改为说do

相关内容