When a command stops, it returns an exit code. You want to learn more about exit codes starting with the variable that stores the most recently completed Linux command's exit code. Every time you use $? in Linux, you get 0. Why is this?
There are four links that can help you learn more. Two are from The Linux Documentation Project (one here and another here). Cyberciti.biz has one. And RedHat's article may still be noted as "unverified." You do not need to go to any of these four.
The Bash built-in variable $? stores the last exit status code. It pertains to a process that has completed. When you run commands successfully, the exit code is 0.
You could try to run this [garbage] command:
Then try this command twice:
# The second time should return a zero because the exit code associated with "exit $?" should have been a "0".
You could also run this script:
echo "This script helps you learn about exit codes."
part1="try this command 'echo $"
part2="?' two or more times"
#Follow what the output of the script says.