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-17 is a script to test a
CVS return value.
Example 6-17. Testing return values
cvs commit -m "Automated commit"
if [ $? -eq 0 ]; then
echo "Commit successful."
else
echo "Commit failed with return code $?"
fiBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access