想测试下跑脚本暂停功能
#!/bin/bash
#!/bin/stty
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#test
function 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 "1"
echo "2"
get_char
echo "3"
运行结果是这样,搞不懂也百度不到答案。
1
2
test1.sh: line 10: SAVEDSTTY=stty -g: command not found
test1.sh: line 11: stty: command not found
test1.sh: line 12: stty: command not found
test1.sh: line 14: stty: command not found
test1.sh: line 15: stty: command not found
test1.sh: line 16: stty: command not found
3
谢谢大神了。