用途說明
exit命令用于退出當前shell,在shell腳本中可以終止當前腳本執行。
常用參數
格式:exit
n
退出。設置退出碼為n。(Cause
the shell to exit with a status of n.)
格式:exit
退出。退出碼不變,即為最后一個命令的退出碼。(If
n is omitted, the exit status is that of the last command executed.
)
格式:$?
上一個命令的退出碼。
格式:trap
"commands" EXIT
退出時執行commands指定的命令。(
A trap on EXIT is executed before the shell terminates.)
退出碼(exit
status,或exit code)的約定:
0表示成功(Zero
– Success)
非0表示失?。∟on-Zero – Failure)
2表示用法不當(Incorrect
Usage)
127表示命令沒有找到(Command
Not Found)
126表示不是可執行的(Not
an executable)
>=128
信號產生
原創文章,作者:會飛的豬,如若轉載,請注明出處:http://www.www58058.com/11106