开发者

Windows batch file && operator

开发者 https://www.devze.com 2023-03-25 18:20 出处:网络
In bash I can write this: #!/bin/sh ant debug && adb install -r bin/Rocher-debug.apk But I have a similar windows batch file, and currently it does this:

In bash I can write this:

#!/bin/sh
ant debug && adb install -r bin/Rocher-debug.apk

But I have a similar windows batch file, and currently it does this:

ant debug
adb install -r bin/Rocher-debug.apk

So, if "ant 开发者_运维技巧debug" fails, it will still run "adb install," and that's not ideal. Do any of you guys know how to do an && equivalent in this situation?

I really have to sit down and properly learn windows scripting some day soon, since I'll be doing a lot of windows work in a few months. But for now a quick answer would be awesome :-)


In cmd.exe the && operator should work essentially the same way, provided your program returns error codes correctly.

ant debug && adb install -r bin/Rocher-debug.apk

Should work.

You can test this the following way:

ant debug
echo %errorlevel%

If this returns zero when it succeeded and non-zero otherwise, then you can use the exact same && that you use in bash.


Check the ant debug success value in Windows ant debug; echo %errorlevel% and then use: if errorlevel <prev_value> adb install .... Most likely the success value will be 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号