6.12. Exit Status
You may at some point want to write a script that includes one or more CVS commands, such as a script to automatically export files from a repository to a web server, or a script to automatically update a test directory and attempt to build a program. If you do, you will need to know whether a given CVS command succeeded.
CVS commands set an exit status when they complete processing. A successful command always returns the success status. A failing command prints an error message and returns the failure status.
The cvs diff command behaves differently from the other commands. It returns success if it finds no differences and failure if it finds differences or encounters an error. This behavior may change in later versions of CVS.
Testing the exit status depends on the operating system. In Unix and Linux, the sh shell variable $? is 0 if CVS returns success, and nonzero if it returns a failure. Example 6-19 shows a script to test a CVS return value, and Example 6-20 shows a Windows version of the same script.
Example 6-19. Testing return values in bash
Example 6-20. Testing return values in Windows