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`