本文介绍了"rem" .bat文件中的注释会导致错误“此时25意外".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是很奇怪吗? .bat rem命令是否具有某种转义代码?

Isn't this weird? Do .bat rem commands have some kind of escape code?

file.bat:

rem https://sourceforge.net/p/jedit/bugs/4084/?limit=25

运行它:

C:\Users\admin>file.bat
25 was unexpected at this time.

C:\Users\admin>https://sourceforge.net/p/jedit/bugs/4084/?limit=25

我没有看到任何错误级别.

I don't see any errorlevel.

推荐答案

rem命令支持一个参数,即/?,对此它很贪心.您的URL包含该字符串.

The rem command supports one argument, namely /?, and it is greedy for it. Your URL contains that string.

=是标准的令牌分隔符(就像,,,;一样),因此其余部分似乎可以解释作为另一个(无效)命令.

The = is a standard token separator (just like , , ,, ;), and so the remainder seems to be interpreted as another (invalid) command.

由于不再检测到/?,因此将注释文本放在引号之间很有帮助:

Putting the remark text in between quotation marks helps here since /? is no longer detected:

rem "https://sourceforge.net/p/jedit/bugs/4084/?limit=25"

当您写这篇文章时:

rem/ https://sourceforge.net/p/jedit/bugs/4084/?limit=25

/?部分也不再被检测到.但是,然后会识别特殊字符,例如&<>|().

the /? portion is no longer detected too. However, special characters like &, <, >, |, ( and ) are then recognised.

另一种替代方法是使用::样式的注释,该注释实际上是无效的标签(标签以:开头,请参见goto /?call /?):

Another alternative is to use a ::-style comment, which is actually an invalid label (labels begin with a :, see goto /? and call /?):

:: https://sourceforge.net/p/jedit/bugs/4084/?limit=25

特殊字符在这里不是问题,但是一定不能在带括号的代码块中使用.

Special characters are not a problem here, but this must not be used within a parenthesised block of code.

这篇关于"rem" .bat文件中的注释会导致错误“此时25意外".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 05:49