Exit vs Return
I can't find out why exit is preferred over return to terminate a batch process. I can see where the trap processing can be useful using return but I think exit utilizes it as well.
Am I safe to continue using return instead of exit? |
From the main code line, they are the same. There is an implicit exit after returning from the main code line.
Use return in functions. Use exit to explicitly exit from anywhere with a status code. |
Quote:
I typically use "return 1" to abend my batch processes and "return 0" to complete the process. return and exit will perform the same in my case right? I ask because out of habit I have changed alot of the existing code from exit to return 1. |
So perhaps we need to clarify what you mean by "batch process".
Consider the following script and output: Code:
$ cat hello_world Code:
$ cat hello_world Code:
$ bash ./hello_world Code:
$ . ./hello_world . Code:
return [n] |
All times are GMT -5. The time now is 06:03 AM. |