I'm assuming you use a bash shell:
Quote:
Originally Posted by massy
what happens if I don't put exit in a shell script?
|
The the script returns the exit status of the last command executed in the script.
In general: An exit status of 0 (zero) tells you that all is OK. Any other status might indicate that something is wrong.
There are exceptions, the grep command being one. 0 means found, 1 means not found and 2 or larger means an actual error. Do check the manual page of the command to see which exit statuses can be generated.
Quote:
and what happens if I put exit 10000 in the end of a shell script?
|
10000 is an illegal number.
An exit status can be anything from 0 (zero) to 255. If you use a larger number bash will reduce it to the 0-255 range. In other words:
exit 256 will return 0,
exit 769 returns 1
Quote:
I did it, and after running the script, It showed an error: too many argument, and added some 10000 in the end of the file of shell script code!?why?
|
Not sure if this related to the exit command. I do not get an error when using
exit 10000
BTW: You can check the exit status by running:
echo $?
All the ins and outs regarding exit can be found in the bash manual page (the EXIT STATUS section).