转义以正斜杠和问号开头的批处理文件回显 [英] Escaping a batch file echo that starts with a forward slash and question mark

查看:30
本文介绍了转义以正斜杠和问号开头的批处理文件回显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有点棘手.如何在批处理文件中正确转义以下内容?

Bit of a tricky one. How can I correctly escape the following in a batch file?

echo    /?   display this help text

这种特殊的字符组合被视为ECHO/?"命令:

This particular combination of characters is treated as an "ECHO /?" command:

C:Batch>ECHO       /?    display this help text
Displays messages, or turns command-echoing on or off.

  ECHO [ON | OFF]
  ECHO [message]

Type ECHO without parameters to display the current echo setting.

它不响应脱字符 (^) 转义,即.我试过了 ^/?/^?和 ^/^?.

It does not respond to caret (^) escaping, ie. I've tried ^/? /^? and ^/^?.

注意:作为一种解决方法,我发现在中间插入其他字符足以绕过 ECHO 命令行处理器,例如:

NB: As a workaround, I found that inserting other characters in between is enough to bypass the ECHO command line processor, eg:

echo ...   /?   display this help text

不过,这并不理想,我想知道是否有一种方法可以实现所需的输出,即使用/?在回显消息的开头.

Still, this is not ideal and I wondered if there was a way to acheive the desired output, namely with /? at the start of the echoed message.

推荐答案

对于转义 echo 参数,您可以使用替代语法 echo.:

For escaping echo arguments, you can use the alternative syntax echo.:

echo./?

这篇关于转义以正斜杠和问号开头的批处理文件回显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆