Environment
- bash
Problems
- I don't know how it works when I exec
exit
command in bash function.- exit function or exit script?
- What will the exit code look like?
How to solve
I actually did it, and found out below.
- script execution ended.
- exit code will be set to exit code specified by
exit
command.
Description
cat << EOF > a.sh
exit_func () {
exit 0
}
exit_func
echo 'execute here!'
EOF
sh ./a.sh
echo $?
output
0
cat << EOF > b.sh
exit_func_254 () {
exit 254
}
exit_func_254
echo 'execute here!'
EOF
sh ./b.sh
echo $?
output
254
Top comments (0)