经研究发现高版本的 4NT / Take Command 的 if 命令有一个 bug 。
当判断条件为假的时候 if 命令会忽略其后的和它在同一行的命令分隔符,也就是会把分隔的其它多个命令当作它自己条件执行的一部分,而不是另起一行的命令,不管在命令行还是在批处理中执行都是如此。
比如
if 1==1 echo 1 %+ echo 2
返回结果
1
2
执行正常
但是,如果
if 1==2 echo 1 %+ echo 2
不返回任何结果,第二句 echo 永远不会被执行
但是,如果是在批处理文件中分开写的两行则不受影响
if 1==2 echo 1
echo 2
执行正常
这个 bug 不影响同一行中被分隔的 if 前面的语句
经测试,这个 bug 只在高版本的 4NT / Take Command 中出现,在 8.0 、9.0 、10.0 中有,但在 6.0 、7.0 和 4DOS 中没有。
It has been discovered that there is a bug in the if command of high - version 4NT / Take Command.
When the judgment condition is false, the if command will ignore the command separator in the same line after it, that is, it will treat the other multiple commands separated as part of its own conditional execution instead of commands on a new line, whether executed in the command line or in a batch file.
For example
if 1==1 echo 1 %+ echo 2
The return result is
1
2
Execution is normal.
But if
if 1==2 echo 1 %+ echo 2
No result is returned, and the second echo is never executed.
But if it is written in two separate lines in a batch file, it is not affected
if 1==2 echo 1
echo 2
Execution is normal.
This bug does not affect the statements before the if in the same line.
It has been tested that this bug only occurs in high - version 4NT / Take Command, and exists in 8.0, 9.0, 10.0, but not in 6.0, 7.0 and 4DOS.