I want to know what is exit 99 and why would one use it and what are the significance uses of it.
For example, I'm using exit 99
.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityThere is no significance to exiting with code 99, other than there is perhaps in the context of a specific program.
Either way, exit
exits the shell with a certain exit code, in this case, 99. You can find more information in help exit
:
exit: exit [n]
Exit the shell.
Exits the shell with a status of N. If N is omitted, the exit status
is that of the last command executed.
$?
to get to it.
Apr 17, 2014 at 9:56
In addition to @Chris Down, there is some return code that reserved for the shell, they have special meaning:
RETVAL Meaning
1 General errors
2 Misusage
127 Command not found
You can refer to this for more details.
Normally, if you finish your script at some point with:
exit 0
The shell will get a 0 as the return code. This zero means everything was OK.
However, if your program has found some error condition, you should exit with a non-zero return code, to inform the shell that something has gone wrong. If you don't want to be more specific, you can simply use 1.
exit 1
You can however, inform the shell of particular type of failures by using other numbers. For example, bash
itself returns a 127 for program not found. So if you document the behaviour of your script, you can do something useful after running it by checking the value of the special variable $?
, which holds the return code of the last executed program.
I looked into this a while ago and found that, for example, FreeBDS had some very useful conventions with regards to exit codes, documented in man 3 sysexits
exit
without parameters exits with the status code of the last command run. (see pubs.opengroup.org/onlinepubs/009695399/utilities/exit.html)
Apr 18, 2014 at 7:07
There is a very long-standing convention (in Unix) for return-status ranges:
Exactly what those individual positive and negative numbers mean is up to the programmer. Sometimes you can choose them for compatibility with other similar programs (e.g. Gnu tools). @Gnouc lists some.
No, I'm not aware of any special significance to exit code 99, never seen it used. Maybe it means 'Not enough beer'
See:
Some programmers will supply a lot of different errorcodes starting with 1.
New versions might introduce new specific errorcodes, so which code should be used for
"all other errors / unspecified error" ?
The exit codes will be truncated at 255, so I would choose 99 as an "other error".