如何在 if/else 块中逐字回显右括号? [英] How to echo a closing parenthesis literally in an if/else block?
本文介绍了如何在 if/else 块中逐字回显右括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
if "!%currentuser%program1!" == "None" (
REM EASTER EGG this is here because i am not confident with using the not switch
)
ELSE
(
echo 1)!%currentuser%program1!
)
它崩溃了,因为它说:
echo 1)!%currentuser%program1!
右括号用作 if
语句的结尾,但我希望它在字面上得到回应.
我认为解释器会看到这一点:
The closing parenthesis is used as an end to the if
statement but I want it to be literally echoed.
I think the interpreter sees this:
if "!%currentuser%program1!" == "None"
(
REM EASTER EGG this is here because i am not confident with using the not switch
)
ELSE
(
echo 1
)!%currentuser%program1!
)
最后两行显然是错误的.
我怎样才能让它真正与右括号相呼应?
And the last 2 lines are obviously an error.
How can I make it actually echo the closing parenthesis?
推荐答案
尝试在要回显的括号中添加脱字符 (^) 符号前缀.
Try adding a caret (^) symbol prefix to the bracket you want to echo.
http://www.robvanderwoude.com/escapechars.php
这篇关于如何在 if/else 块中逐字回显右括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文