- #!/bin/sh
- getchar() {
- stty cbreak -echo
- dd if=/dev/tty bs=1 count=1 2> /dev/null
- stty -cbreak echo
- }
- printf "Please input your passwd: "
- while : ; do
- ret=`getchar`
- if [ x$ret = x ]; then
- echo
- break
- fi
- str="$str$ret"
- printf "*"
- done
- echo "Your password is: $str"
这样密码显示都是*,想不到shell还能玩到这种地步。
阅读(1597) | 评论(0) | 转发(0) |