Disclaimer: I know Perforce very well, but .bat
syntax barely at all. I have no real idea of what any of that FOR
line is doing beyond the very general notion that it's iterating over the output of p4 opened
.
I think the issue is that your script expects p4 opened
to print just the filename, when the reality is that it prints output like this:
C:Perforceest>p4 opened ...
//stream/test/bar#1 - edit default change (text)
The error you're seeing is probably due to that FOR
statement trying to parse that line of output and tripping over the -
character.
A very easy fix is to use p4
's -F
global option to reformat the output into just the file path:
C:Perforceest>p4 -F %depotFile% opened ...
//stream/test/bar
hence:
@echo off
cls
FOR /F "delims=" %%i IN ('p4 -F ^%depotFile^% opened ...') DO set open_files=%%i
echo %open_files%
if %open_files% =="" (
echo No file are in pendig list
goto execute
) else (
echo files are in pending list, please submit them if needed or revert them
echo %open_files%
goto eof
)
:execute
<Do something>
:eof
prints:
opened
files are in pending list, please submit them if needed or revert them
opened
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…