【发布时间】:2018-05-27 08:10:47
【问题描述】:
我在 bash 脚本中编写了这段代码。当我运行它时,提示“开始?[y/n]”,但无论我响应什么,它都会关闭窗口。另外,if 语句的正确语法是什么。
@echo off
set /p choice="Start? [y/n] "
echo $choice
echo $choice$
if $choice$ == "y"
then
goto Labelyes
fi
if $choice$ == "n"
then
exit
fi
:Labelyes
echo YAY
set /p goodbye="BYE"
if [1==1]; then exit; fi
谢谢!
【问题讨论】:
-
这不是
bash,对于初学者来说。它看起来更像一个 DOS 批处理脚本。 -
使用“读取”命令:stackoverflow.com/questions/226703/…
-
学习基本的 Bash 教程,有很多,只需在搜索引擎中输入“bash tutorial”。