As an assignment in school, we have to write a C++ program and returns different error codes in the main
.
The problem is that we have to return -2
Unix, and linux are limited to 8 bit return codes, -2 is 0xfe. Which your shell will understand to be 254 when you echo $?
You're expected to give a return code between 0 and 255.
http://en.wikipedia.org/wiki/Exit_status
on POSIX-compatible exit statuses are restricted to values 0-255, the range of an unsigned 8-bit integer.