【发布时间】:2021-06-16 19:25:38
【问题描述】:
#! bin/bash
echo "Hello what is your first name."
read name
if [ $name ]; then
echo "$name, that's a funny name"
else
echo "I asked for your name, you better answer me, i'll give you another chance, this time you better answer me, you understand, YES or NO"
read response
if [ $response ]; then
echo "Then tell me WHAT IS YOUR NAME"
read name
echo "Finally, thank you, bye $name"
else
echo "Say goodbye to your family"
fi
【问题讨论】:
-
尝试正确缩进你的代码。
-
我错过了第二个
fi。 -
为了帮助调试 shell 脚本,请使用shellcheck.net
-
在询问问题时,您需要描述问题所在。什么时候出现问题?它做什么/不做什么,这与你想要的有什么不同?您是否收到任何错误消息(如果有,请报告确切错误消息)。请参阅how to ask a good question 上的帮助条目。
-
你想用
if [ $name ]实现什么?