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 關注
- 930 瀏覽
添加回答
舉報