SVN Pre Commit Hooks

不问归期 提交于 2019-12-05 21:05:52

findstr returns 0 if something has been found, and 1 if nothing has been found. You just inverted your check.

No batch-foo required, even on Windows the shell is interactive, so you can try it out alive:

>dir | findstr ".sln"
15.01.2009  16:37            33.844 Project.sln

>echo %ERRORLEVEL%
0

>dir | findstr ".slngimpf"

>echo %ERRORLEVEL%
1

Btw, it easier to write

if errorlevel 0 andthencontinuewithwhatever

This way you script is also stable against the ominous:

set errorlevel=0

which will then destroy any future attempt to print out the errorlevel with %errorlevel% in a correct way.

(edit) Important note: I forgot to say that the if errorlevel syntax checks whether the errorlevel is greater or equal to the value being tested for. So to correctly use it, you must always check for the highest error first, like:

someCommand
if errorlevel 10 ...
if errorlevel 9 ...
if errorlevel 0 ...

Not exactly the answer you are looking for, but you can block all *.suo files with the global-ignores option.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!