exit 1 and exit 2 both end a process. The difference is that they pass different values to the calling program. For example:
# main program commands
script_ar
if [ "$?" -ne 0 ]
then
echo "error returned from script_ar"
if [ "$?" -eq 1 ]
then
echo "error 1 = bad filename"
fi
if [ "$?" -eq 2 ]
then
echo "error 2 = bad record count"
fi
fi
The above main program calls script_ar. It analyzes the return value (the 1 or 2 you asked about). If the value is set, the program echo's an error and then specific error information that you designed into the routines.
It is normally good programming practice to use
exit 0
when ending a program that ran correctly
exit 1 (or other number)
when ending a program that had a problem