The documentation for the command line as per Arduino IDE 1.5 from command line · arduino/Arduino Wiki · GitHub says a successful return from the command line invocation should be zero. 1 and 2 represent failures.
My investigations indicate that zero is not returned but rather 259 is for success!!! Is this a bug?
It also appears that the return code is generated before the Arduino IDE (which is invoked to perform this) has actually completed... hmmm
system
3
Under Windows arduino.exe exits with ErrorLevel 0 or 259 before compilation begins (but IDE runs at background)
arduino.exe
ErrorLevel = 259
START /WAIT arduino.exe
ErrorLevel = 259
START arduino.exe
ErrorLevel = 0
This behavior is not very convenient for batch processing commands