I shell scripting what does the exit -1 means?
I shell scripting what does the exit -1 means?
Who wrote the script? Meaning of non-zero exit is often attributed by the author.
Some standard definitions are usually located in errno.h
You can find this, e.g. at /usr/include/asm-generic/errno.h
Now, -1 is a special number because in two's complement binary representation it corresponds to all 1's (255 for an 8 bit integer)
I think it usually corresponds to "unknown error," though I may be totally mistaken.
If you're a C programmer, the "perror()" function will
print the traditional meaning of an error code for you and "strerror()" will return it as a string.
Here's some quick (not guaranteed to be perfect) example code:
Code:#include <stdio.h> #include <string.h> int main(int argc, char* argv[]) { int i; for(i=1;i<argc;i++) printf("%d: %s\n",atoi(argv[i]), strerror(atoi(argv[i]))); return 0; }
References:
`man errno`
http://www.gnu.org/s/bash/manual/htm...it-Status.html
Last edited by countach44; 12-16-2011 at 03:08 PM. Reason: spelling, added example code
63,000 bugs in the code, 63,000 bugs,
ya get 1 whacked with a service pack,
now there's 63,005 bugs in the code!!
sure, I dint write the script, I was going through the script and noticed exit -1 in the code and I am unable to figure it out how and what it does.. Still I am in confusion
Is the script in bash? Running it with "bash -x" will give more detail about what it's doing (you'll probably want to redirect output to less, e.g. bash -x script.sh | less).
If you can find a snippet of relevant code and post it, maybe someone here can help you out.
63,000 bugs in the code, 63,000 bugs,
ya get 1 whacked with a service pack,
now there's 63,005 bugs in the code!!
Bookmarks