Windows operation file and operator b

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 is not ideal. Do any of you guys know how to do && equivalently in this situation?

I really need to sit down and learn windows scripting correctly soon, since in a few months I will be making a lot of windows. But for now the quick answer will be awesome :-)

+6
source share
2 answers

In cmd.exe, the && operator should work differently if your program correctly returns error codes.

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

Must work.

You can check it as follows:

 ant debug echo %errorlevel% 

If this returns zero when it succeeds, and otherwise a non-zero value, you can use the same && that you use in bash.

+9
source

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

0
source

Source: https://habr.com/ru/post/894093/


All Articles