更新时间:2023-02-19 09:34:04
问题是 if 3 == 3
部分后的括号分组
The problem is the parentheses grouping after the if 3==3
part.
当解析 set JAVA_HOME =%SUN_JAVA_HOME%
命令时,解释器立即替换%SUN_JAVA_HOME%
变量,这会导致(386)
中右括号的早期匹配。
While parsing the set JAVA_HOME=%SUN_JAVA_HOME%
command, the interpreter immediately replaces the %SUN_JAVA_HOME%
variable and that causes an early match of the closing parenthesis in (386)
.
如果启用延迟了扩展,并将%SUN_JAVA_HOME%
替换为!SUN_JAVA_HOME!
:
This can be avoided if you enable delayed expansion and replace %SUN_JAVA_HOME%
with !SUN_JAVA_HOME!
:
setlocal enabledelayedexpansion
set SUN_JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_17
if 3==3 (
set JAVA_HOME=!SUN_JAVA_HOME!
)
echo ready