1 回答
TA贡献1852条经验 获得超7个赞
从来没有使用:label也没有:: label-like comment封闭在命令块内部()的括号。证明:
@ECHO %1>NUL
if "" == "" (
@echo a simple echo, no comments
)
if ""=="" (
@echo a rem comment follows this echo command
rem comment
@echo a rem comment precedes this echo command
)
if ""=="" (
@echo a label-like comment follows this echo command
:: comment
@echo a label-like comment precedes this echo command
)
if ""=="" (
@echo a label follows this echo command
:label
@echo a label precedes this echo command
)
输出:
==>D:\bat\labels.bat OFF
a simple echo, no comments
a rem comment follows this echo command
a rem comment precedes this echo command
a label-like comment follows this echo command
'@echo' is not recognized as an internal or external command,
operable program or batch file.
a label follows this echo command
'@echo' is not recognized as an internal or external command,
operable program or batch file.
==>
如果我可以理解您的目标,那么下一个代码段应该可以按预期工作:
SETLOCAL enableextensions
rem (set `svnroot_temp` and `choice` variables here)
if /i "%choice%"=="1" (
cls
svn ls %svnroot_temp%
call :top
)
goto :eof
:top
set /p direct=Enter directory:
if /I "%direct%"=="checkout" goto :checkout_area
set "svnroot_temp=%svnroot_temp%\%direct%"
svn ls %svnroot_temp%
goto :top
:checkout_area
请注意,两个比较表达式if /I "%direct%"=="checkout" goto :checkout_area都用双引号引起来,因为任何用户输入都可能包含空格,甚至可能为空。
不确定要引用svn ls "%svnroot_temp%"。
不确定命令"%svnroot_temp%"的输入目录还是输出目录svn ls:
如果输入:if not exist "%svnroot_temp%\%direct%\" goto :top 在更改之前先检查使用set "svnroot_temp=%svnroot_temp%\%direct%"
万一输出:更改MD "%svnroot_temp%" 2>NUL 后使用创建。
- 1 回答
- 0 关注
- 872 浏览
添加回答
举报