我正在学习批处理脚本,我复制了如何检查空的示例:
@echo off
SET a=
SET b=Hello
if [%a%]==[] echo "String A is empty"
if [%b%]==[] echo "String B is empty "
Run Code Online (Sandbox Code Playgroud)
但我收到这样的错误:
D:\Projects\Temp\BatchLearning>Script.bat
]==[] was unexpected at this time.
Run Code Online (Sandbox Code Playgroud)
什么问题?为什么这是在指南中。过去有用吗?从这里的例子。
更新:
我删除了第 2、3 和 5(最后)行末尾的一些空格,现在一切都按预期工作,这是怎么回事?