admin 管理员组

文章数量: 887021


2024年1月22日发(作者:apache hive)

2. ^Csorry! I habe trapped Ctrl+C3. LOOP #74. ^Csorry! I habe trapped Ctrl+C5. LOOP #86. LOOP #97. LOOP #108. this is the end of the test program9. goodbye0. [root@localhost shell]#还可以在shell中移除捕捉,代码如下:

1. [root@localhost shell]# cat -n 2. 1 #!/bin/bash3. 2 trap "echo 'sorry! I habe trapped Ctrl+C'" SIGINT SIGTERM4. 3 trap "echo goodbye" EXIT5. 4 echo this is a test program6. 5 count=17. 6 while [ $count -le 10 ]8. 7 do9. 8 echo "LOOP #$count"0. 9 sleep 11. 10 count=$[ $count + 1]2. 11 done3. 12 echo this is the end of the test program4. 13 trap - EXIT5. 14 echo " I just remove EXIT trap "在程序结束之前,移除了EXIT捕捉,最终就不会输出goodbye:


本文标签: 捕捉 不会 结束 程序 移除