About
exit is a builtin command and cause the shell to exit with a given exit status.
Syntax
exit [n]
- n is the exit status of n.
If n is omitted,the exit status is that of the last command executed.
Post function
A function can be called on a EXIT before the shell terminates.
Example: by calling the exit function, the following finish function will run thanks to the registration of the function via the trap utility
#!/bin/bash
function finish {
# Your cleanup code here
}
trap finish EXIT