澄清bash陷阱

澄清bash陷阱,bash,Bash,我目前正在学习bash教程: 我来到了我很难理解的部分: #!/bin/bash # bash trap command trap bashtrap INT # bash clear screen command clear; # bash trap function is executed when CTRL-C is pressed: # bash prints message => Executing bash trap subrutine ! bashtrap() { e

我目前正在学习bash教程:

我来到了我很难理解的部分:

#!/bin/bash
# bash trap command
trap bashtrap INT
# bash clear screen command
clear;
# bash trap function is executed when CTRL-C is pressed:
# bash prints message => Executing bash trap subrutine !
bashtrap()
{
    echo "CTRL+C Detected !...executing bash trap !"
}
# for loop from 1/10 to 10/10
for a in `seq 1 10`; do
    echo "$a/10 to Exit." 
    sleep 1;
done
echo "Exit Bash Trap Example!!!"

您具体在哪里指定ok trap
CTRL+C
?这一行
trap bashttrap INT
?INT是什么意思?

INT
SIGINT
或“键盘中断”,即Ctrl+C引起的信号


如果您使用的是Linux,请参阅手册页
signal(7)
,了解有关
SIGINT
和其他信号的更多信息。

INT
SIGINT
或“键盘中断”,即Ctrl+C引起的信号


如果您使用的是Linux,请参阅手册页
signal(7)
,了解有关
SIGINT
和其他信号的更多信息。

也许您可以添加有关如何访问手册页的Linux命令也许您可以添加关于如何访问手册页的Linux命令