1. The
exit command
terminates a script. It can also
return a value, which is available to the script's parent process.
2. $? reads the exit
status of the last command executed. After a function returns, $? gives the exit
status of the last command executed in the function. Following the execution of a pipe, a $? gives the exit status of the
last command executed. After a script terminates, a $? from the command-line gives the exit status of the script, that is, the
last command executed in the script.
3. The !, the logical not qualifier, reverses the outcome of a test or command, and this affects its exit status.
-
! true # Note that the "!" needs a space between it and the command.
-
echo "exit status of \"! true\" = $?" # 1
阅读(1802) | 评论(0) | 转发(0) |