实际上我需要编写一个批处理脚本,首先我需要检查所需的客户端规范是否已经存在? 如果存在那么我应该删除它。
如果所需的客户端规范存在或不存在,您能否告诉我们如何 checkin 脚本?
最佳答案
在 Windows 命令行上,你可以执行类似的操作
set P4CLIENT=client-name
p4 clients -e %P4CLIENT% | findstr %P4CLIENT% >nul
p4 client -e %P4CLIENT%
将输出匹配 %P4CLIENT%
的所有客户端。 findstr
将在 p4 客户端
的输出中搜索客户端名称并打印它。重定向到 nul
将抑制此输出,但 findstr
将另外设置 %errorlevel%
变量。
一些例子:
p4 clients -e existing-client | findstr existing-client >nul
echo %errorlevel%
将返回 0。
p4 clients -e does-not-exists | findstr does-not-exists >nul
echo %errorlevel%
将返回 1。
如果您想执行某些操作,如果给定的客户端空间不存在,您可以运行以下命令:
p4 clients -e does-not-exists | findstr does-not-exists >nul || create-client.bat
如果你想执行某些操作,如果给定的客户端空间确实存在,你可以运行以下命令:
p4 clients -e does-not-exists | findstr does-not-exists >nul && do-something.bat
感谢来自 perforce 在线聊天支持的 Adam!
关于强制 : Is there any command to check if client spec exist or not,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19631132/