2016-11-22 16 views

回答

2

您可以使用ERRORLEVEL看是否最后一个命令失败或不

这样

if %ERRORLEVEL% == 0 GOTO continue 
if %ERRORLEVEL% == 1 GOTO error 

:continue 
    echo do what you want here after successfully cloned 
    goto exit 

:error 
    echo do your error handling here 

:exit 
1

在poweshell你可以可以调用命令,然后检查$lastexitcode变量,如果命令完成它会如果它失败,则为0,它将为1。使用简单的if你可以处理如下:

call git clone ssh://[email protected]/~/repo/site C:\git\project 

if ($lastexitcode) { 
    Write-Host "Failed" 
    #error handling code here 
} 
else { 
    Write-Host "Completed" 
}