#!/bin/sh

getStr(){
  x=0
  while : ;do
      char=`
          stty cbreak -echo
          dd if=/dev/tty bs=1 count=1 2>/dev/null
          stty -cbreak echo
      `
      if [ "$char" =  "" ];then
          break
      fi
      if [[ "$ret" == $(echo -ne '\b') ]];then
          if [ $x -eq 0 ];then
              continue
          fi
          password="${password%?}"
          printf "33[1D"
          printf "33[K"
          let x--
          continue
      fi
      password="$password$char"
      # echo -n "*"
      let x++
  done

  echo "$password"
}

echo $(getStr)

