shell脚本Ctrl+C终止判断:

get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo -e "\033[31mPress any key to continue or press Ctrl + C to cancel.\033[0m"
char=`get_char`